<select ...<option (tag problem)
Posted: Sun Jun 15, 2008 6:22 am
i have problem with this javascript code. i can not access to this value : window.document.theform.select1.op2.value; and i got error! please help me.
Code: Select all
<script language = "javascript">
function disp()
{
//document.write('information was sent');
window.document.theform.txt1.value = "admin logged!";
window.document.theform.txt2.value = window.document.theform.select1.value;
window.document.theform.txt3.value = window.document.theform.select1.op2.value; [color=#FF0000]// this line of code causes error[/color]
}
</script>
<form action='test.php' method = 'post' name='form1' id='theform'>
<input type = 'text' id='txt1' name='textbox1'>
<p>
<input type = 'text' id='txt2' name='textbox2'>
<p>
<input type = 'text' id='txt3' name='textbox3'>
<p>
<select name="Greeting" id="select1">
<option id = "op1" name = "nop1" value="Hello">Hello</option>
<option id = "op2" name = "nop2" value="Hola">Hola</option>
<option id = "op3" name = "nop3" value="Bonjour">Bonjour</option>
</select>
<input type = 'button' id='btn' name = 'button1' value = 'sendit' onclick = 'disp();'>
</form>