I want to change written value of JavaScript after I change the value of ComboBox, but it didn’t work. Here is my code :
<script>var selGate = "empty"</script>
<SELECT NAME = "cmbGate" STYLE ="width: 600px" SIZE = 15 onchange="chGate()">
<OPTION Value = "opt1">Option 1</OPTION>
<OPTION Value = "opt2">Option 2</OPTION>
</SELECT>
<BR>
<form name="frGate">
Selected Gate is:
<script>document.write(selGate)</script>
</form>
<script>
function chGate()
{
selGate = document.getElementsByName("cmbGate").selectorText;
frGate.submit();
}
</script>
You function would look like this:
You html should change like this:
==> Change the select
==> Change the form
See a working demo:
http://jsfiddle.net/Mr2CF/2/