|
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?
irt.org | Knowledge Base | JavaScript | Form 11 | Q1197 [ previous next ]
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 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?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.