You are here: irt.org | FAQ | JavaScript | Form | Q1396 [ previous next ]
Several things:
Try:
<script language="JavaScript"><!-- function transfer() { var defaultSelected = true; var selected = true; var optionName = new Option(document.leftForm.leftSelect.options[document.leftForm.leftSelect.selectedIndex].text, document.leftForm.leftSelect.options[document.leftForm.leftSelect.selectedIndex].value, defaultSelected, selected) var length = document.rightForm.rightSelect.length; document.rightForm.rightSelect.options[length] = optionName; history.go(0); } //--></script> <table><tr><td> <form name="leftForm"> <select name="leftSelect"> <option value="1">one <option value="2">two </select> <input type="button" value="Transfer" onClick="transfer()"> </form> </td><td> <form name="rightForm"> <select name="rightSelect" multiple> </select> <input type="submit" value="Submit" </form> </td></tr></table>
Note the above will not work in Internet Explorer 3, as it does not support the addition of options to a select form field.