Forum Moderators: open
does anyone know if you can set the selected value of a <select> after its been declared?
<form name="myForm" action="somewhere">
<select name="test">
<option value='0'>--- Select your Option ---
<option value="1">Option 1
<option value="2">Option 2
<option value="3">Option 3
</select>
</form>
<insert clever javascript here to set that form's selected value to the option with value 2 for example> :)
cheers for the help if you help!
<script type="text/javascript">
window.onload = function() {
// Select the 3rd item in the list (index begins with zero)
document.getElementById("mySelect").selectedIndex = 2;
}
</script>