Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1197 Using drop down select option menus, can I add include additional data with each option, but not as part of either its value or text properties?

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>

Feedback on 'Q1197 Using drop down select option menus, can I add include additional data with each option, but not as part of either its value or text properties?'

©2018 Martin Webb