ProblemThe select object's value property doesn't give the selected value
BrowserInternet Explorer
ExampleThe select drop down:
[HTML]<select name="test" id="test">
<option>1
<option>2
</select>[/HTML]
The Javascript code:
- var selObj = document.getElementById("test");
- var val = selObj.value;
SolutionGive values to the option elements:
[HTML]<select name="test" id="test">
<option value="1">1
<option value="2">2
</select>[/HTML]
Alternative SolutionChange the Javascript to:
- var selObj = document.getElementById("test");
- var val = selObj.options[selObj.selectedIndex].text;
No comments:
Post a Comment