You are here: irt.org | FAQ | JavaScript | Form | Q1236 [ previous next ]
Enumerate the values:
<form name="myForm"> <select name="mySelect> <option value="1">zero <option value="x">one <option value="qwerty">two <option value="">three </select> </form> <script language="JavaScript"><!-- for (var i=0;i<document.myForm.mySelect.options.length;i++) { if (document.myForm.mySelect.options[i].value == 'qwerty') document.myForm.mySelect.options[i].selected = true; } //--></script>