Hi,
I am having problem to get a value of the selected item from a dropdown
listbox.
Here is the JS function;
function getSelectedItem (objSelect) {
alert("in getSelectedItem ");
alert (objSelect.leng th);
alert (objSelect.valu e);
for (i=0; i<objSelect.len gth; i++) {
alert("recahed here.."+i)
alert (objSelect[i].value);
if (objSelect[i].selected) {
return objSelect[i].value;
}
}
return "";
}
here is corresponding html:
<form name="main_form ">
<table>
<tr><td>
<select name="assigned_ num">
<option value='null'>-- Select Number --</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<input type="button" class="button" value="Add"
onclick="javasc ript:getSelecte dItem('assigned _num:
'+document.main _form.assigned_ num.value);">
</td></tr>
</table>
</form>
What s wrong with this code and what s the correct implementation for
retrieving a selected value from the listbox( or dropdown listbox)?
Thanks
A