why does this only work if the [COLOR=Red]var a=document.form1.myselect
<html xmlns=”
<head><script type=”text/javascript”>
[COLOR=Red]var a=document.form1.myselect;
function myfunc(){
[COLOR=Red]// THIS WORKS — var a=document.form1.myselect;
alert(a.options[a.selectedIndex].value);
}
</script>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>
<body>
<form id=”form1″ name=”form1″ method=”post” action=””>
<label>
<select name=”myselect” id=”myselect”>
<option value=”oneone”>one</option>
<option value=”twotwo”>two</option>
<option value=”threethree”>three</option>
</select>
</label>
<p> </p>
<p><input type=”button” value=”click me” onclick=”myfunc()” /> </p>
</form>
</body>
</html>
Thank you