You are here: irt.org | FAQ | JavaScript | Form | 4 | Q556 [ previous next ]
Internet Explorer 3 does not support the addition and removal of options from drop down boxes, but apart from that try:
<script language="JavaScript"><!-- function transferOption(object) { var index = object.dropdownlistA.selectedIndex; if (index > -1) { var newoption = new Option(object.dropdownlistA.options[index].text, object.dropdownlistA.options[index].value, true, true); object.dropdownlistB.options[object.dropdownlistB.length] = newoption; if (!document.getElementById) history.go(0); object.dropdownlistA.options[index] = null; object.dropdownlistA.selectedIndex = 0; } } //--></script> <form name="formName"> <select name="dropdownlistA"> <option value="Option 0">Entry 0 <option value="Option 1">Entry 1 <option value="Option 2">Entry 2 <option value="Option 3">Entry 3 <option value="Option 4">Entry 4 <option value="Option 5">Entry 5 </select> <select name="dropdownlistB"> </select> <p> <input type="button" value="Transfer" onClick="if (document.images) transferOption(this.form)"> </form>