Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
37
rated 0 times [  44] [ 7]  / answers: 1 / hits: 81774  / 15 Years ago, sun, may 24, 2009, 12:00:00

HTML Javascript question



to get the selected value of a input-select I can use



<select id=gender name=gender class=style12>
<option selected=selected>ALL</option>
<option>Male Only</option>
<option>Female Only</option>
</select>

document.getElementById('gender').value


is there any easy way for me to get the selected label (i.e. ALL / Male Only / Female Only) with javascript?



Thanks a lot for reading.


More From » html

 Answers
14
var el = document.getElementById('gender');
var text = el.options[el.selectedIndex].innerHTML;

[#99467] Wednesday, May 20, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jamir

Total Points: 736
Total Questions: 97
Total Answers: 101

Location: Cayman Islands
Member since Fri, Mar 4, 2022
2 Years ago
;