A
acord
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.length);
alert (objSelect.value);
for (i=0; i<objSelect.length; i++) {
alert("recahed here.."+i)
alert (objSelect.value);
if (objSelect.selected) {
return objSelect.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="javascript:getSelectedItem('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
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.length);
alert (objSelect.value);
for (i=0; i<objSelect.length; i++) {
alert("recahed here.."+i)
alert (objSelect.value);
if (objSelect.selected) {
return objSelect.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="javascript:getSelectedItem('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