> I didn't get my message clear enough. My var already has a value. My
dropdownbox is already populated with <options>'s. What I want to know
is can my var be matched with the <option>'s directly and the <option>
get executed.
Well you still left a few things unspecified, but guessing at those,
this code should do the trick:
<html>
<head>
<!-- var already has value, I'm setting it here -->
<script language="javascript">
var myvar = "somevalue";
</script>
</head>
<body>
<!-- your dropdownbox with its options, set in html -->
<form action="somescript.cgi">
<select size="1" name="mybox">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</form>
<!-- now change contents of the box -->
<script language="javascript">
// empty the box
while (document.forms[0].mybox.options.length)
document.forms[0].mybox.options[0] = null;
// put var in the box
document.forms[0].mybox.options[document.forms[0].mybox.length]
= new Option(myvar, myvar);
// now set which option must be selected.
// required in NS4, and handy in IE when you want
// to select an option that doesn't come first
document.forms[0].mybox.selectedIndex = 0;
// now "execute" the dropdownbox: do you mean submitting the form?
// if so, uncomment this line:
// document.forms[0].submit();
</script>
</body>
</html>
Bart