Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Netscape and Select tag


Message #1 by "Michael Bain" <michael.bain@m...> on Thu, 25 Oct 2001 17:41:04
Michael,

this code works in IE, Netscape 4, Netscape 6, Mozilla 0.9.5, Opera 5.


<html>
<head>
	<title>Change selected index</title>
	
<script language="JavaScript" type="text/javascript">
<!--
	window.onload = function (){
		document.theForm.theSelect.selectedIndex = 2;
	}
//-->
</script>	
	
</head>

<body>

<form id="theForm" name="theForm">
	<select id="theSelect" name="theSelect">
		<option>One</option>
		<option>Two</option>
		<option>Three</option>
		<option>Four</option>
	</select>
</form>	
	


</body>
</html>


/Robert


-----Original Message-----
From: Michael Bain [mailto:michael.bain@m...] 
Sent: den 25 oktober 2001 19:41
To: javascript
Subject: [javascript] Netscape and Select tag


We are trying to set the value of a Select combo box via Javascript code.  
Here is the code that we are using, but it only works in IE.  Any insights 
on how to do this on Netscape?

     document.FormName.ObjectName.value = "2";

I have also tried using the selectedIndex property like so...

     document.FormName.ObjectName.selectedIndex = "1";

Thanks...Mike

  Return to Index