I have a dropdown which lists heights, like this:
5' 9"
5' 10"
5' 11"
6' 0"
Etc.
When I view source, it looks like this:
<option value="5' 9"">5' 9"</option>
<option value="5' 10"">5' 10"</option>
<option value="5' 11"">5' 11"</option>
<option value="6' 0"">6' 0"</option>
How can I set the selected value of my dropdown box via Javascript when those characters are in there?
I tried:
document.GetElementById("myDDL").value = '5\' 11\"';
However that is not working and I'm just taking stabs in the dark.
Thank you!
I have a dropdown which lists heights, like this:
5' 9"
5' 10"
5' 11"
6' 0"
Etc.
When I view source, it looks like this:
<option value="5' 9"">5' 9"</option>
<option value="5' 10"">5' 10"</option>
<option value="5' 11"">5' 11"</option>
<option value="6' 0"">6' 0"</option>
How can I set the selected value of my dropdown box via Javascript when those characters are in there?
I tried:
document.GetElementById("myDDL").value = '5\' 11\"';
However that is not working and I'm just taking stabs in the dark.
Thank you!
Share Improve this question asked Feb 11, 2010 at 9:11 user53885user53885 3,82912 gold badges36 silver badges45 bronze badges3 Answers
Reset to default 3Works fine for me on Safari 4, MobileSafari 3.1, Firefox 3.5 and Opera 10.10
Did you try
document.getElementById("myDDL").value = '5\' 11"';
with a small g
?
If you know in advance which option you want to select, you could do
document.getElementById("myDDL").selectedIndex = 2; // 5' 11"
$("#single_example").val(2).trigger("change");