SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2008
    0 Post(s)
    0 Thread(s)

    Jquery select box set to "selected"

    Hey, I have a select box with the id of "age". I would like to have jquery set the correct age to selected. I have an invisible text box that has the age in it and javascript picks up the current age from this text box. Here is how the select box looks. My problem is getting the right <option> to be selected. Say for example purposes the <option> I want selected is 30. How would I go about getting it selected?

    HTML Code:
    <select name="age" id="age">
    <option value="20">20</option>
    <option value="30">30</option>
    <option value="40">40</option>
    Thanks so much.

    EDIT: Found the answer. All you have to do is:

    HTML Code:
    Last edited by PHP Monkey; Dec 1, 2008 at 11:35.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts