View Full Version : jQuery how to select from drop down

12-01-2010, 06:29 PM
question: how to select the 7th value in my dropdown menu ?


this drop down menu is generated by my php function inside a model of my mvc app like this

public function getSecretQuestions()
return array(
0 => 'What is your favourite Colour?',
1 => 'What is your mothers Maiden Name?',
2 => 'What is your Pets Name?',
3 => 'What was your first telephone number?',
4 => 'What was your favourite teachers name?',
5 => 'What is the title of your favourite film?',
6 => 'What is the name of your favourite book?',
7 => 'Write my own question',

so how am i gonna select the 7th key value pair using jquery given the id of the drop down menu in order for me to show a text box ? :confused:

12-01-2010, 08:49 PM
If your resultant html is similar to:

<select id="selector">
<option value="Number seven">Seven</option>



will return the 7th option value - "Number seven" in my example.

If you're trying to set the seventh option as selected: