Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrew Platt
2,036 PointsDrop Down box
I have a wordpress site that use an appointment plug in called "appointzilla" so users can select a date and service of their choosing and schedule with the owner of the site, my client.
The site url is: http://myimmigrationadvice.com/book-your-appointment/
What I would like to know is can I use one of the values in the drop down box under the heading "Select Service:" to display one of the options when the page loads instead of the current default value which is "Select Service." Any help is appreciated, thanks!
1 Answer
Brett Smith
4,261 PointsFound a simple jQuery solution:
jQuery(document).ready(function($){
$('select option:contains("Deposit (30min/$500)")').prop('selected',true);
});
I tried it in the Chrome Console and it worked on your site. There may be a simpler method but this one seems to work for me. You can literally copy and paste the text of the option you would like selected into the parenthesis... just don't forget the quotes.
Andrew Platt
2,036 PointsAndrew Platt
2,036 PointsThat code works perfectly thank you very much I appreciate your help!
Brett Smith
4,261 PointsBrett Smith
4,261 PointsGlad I could help, Andrew. I'd love for you to select as best answer if it's not too much trouble!
Andrew Platt
2,036 PointsAndrew Platt
2,036 Pointsof course no problem at all, thanks again!