You are here: irt.org | FAQ | JavaScript | Form | 11 | Q1197 [ previous next ]
You can use an array to hold additional information that can be retrieved later in the script. For example:
<script language="JavaScript"><!-- theDesc = new Array( 'Please select an ID' 'Desc 1', 'Desc 2', 'Desc 3'); //--></script> <form> <select onChange="this.form.desc.value=theDesc[this.selectedIndex];"> <option value="">--- Select an ID --- <option value="id1">ID1 <option value="id2">ID2 <option value="id3">ID3 </select> <input type="text" name="desc" style="border:none"> </form>
If you do not want the desc to be sent to the server too, you can take it out of the form and put it in another:
><script language="JavaScript"><!-- theDesc = new Array( 'Please select an ID' 'Desc 1', 'Desc 2', 'Desc 3'); //--></script> <table> <tr> <td> <form> <select onChange="document.descform.desc.value=theDesc[this.selectedIndex];"> <option value="">--- Select an ID --- <option value="id1">ID1 <option value="id2">ID2 <option value="id3">ID3 </select> </form> </td> <td> <form onSubmit="return false"> <input type="text" name="desc" style="border:none"> </form> </td> </tr> </table>