0

How can i get a selected value from combo box ? i used combo.selectedItem.But it is not working.will u pls give me a solution for this

3
Contributors
6
Replies
7
Views
11 Years
Discussion Span
Last Post by sn4rf3r
0

HTML doesn't have a "combobox" control. Do you mean a "select" element? If your select element has an id of "x", you would get the value of the selected option: x.options[x.selectedIndex].value; Proper terminology is very important in any technical discussion.

0

you can have a hidden field in your form, and then set the value using js before it is passed to php.

<script>
var hidden=document.getElementById('myfield');
hidden.value='whatever you want'
</script>
<input type="hidden" id="myfield" name="myfield" value="" />
0

<body>
<form>
<select name="wcode" onChange="disp(this.form)">
<option value="1">India</option>
<option value="2">Pakistan</option>
<option value="3">Nepal</option>

</select>
<?php
id=$_get;

?>
</form>
</body>

<script>
function disp(frm)
{
var index=frm.wcode.selectedIndex;
var value=frm.wcode.options[index].value;
var item=frm.wcode.options[index].text;
document.action=worksfwdtogovt.php?id=+value;
document.worksfwdtogovt.submit();
}//disp


is this script return the index value to form.if not .pls give correct syntax.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.