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

Recommended Answers

All 6 Replies

please post the relevant code.

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.

Is it possible to return a value from java script to php form.if possible how?

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="" />

<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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.