Nimmi wrote:
> > the only way to get the label is putting that as part of the value and
> > extracting it from the result of getDisplayFieldValue("ComboBox1").
Andy wrote:
> This limitation is a consequence of HTML and how comboboxes et. al.
> are represented. The labels as such are never sent back to the server
Hi Nimmi,
If you know all your users have JavaScript, for example if you develop a
corporate intranet with Netscape 4+ or MSIE 4+, then there's a trick.
The first HTML page below shows how to use JavaScript to determine
the index and label of a select-one box. The second HTML page below
shows how to automate the trick for all of the select-one boxes.
When you try the pages, be sure you can see the URL in your browser.
You will see the hidden text fields getting filled correctly.
If your users might have older browsers, or might have JavaScript off,
then go with Andy's solution; his is much more robust and flexible.
Cheers,
Joel
home: [EMAIL PROTECTED]
work: [EMAIL PROTECTED]
---------------------------------------------------------------
<html><body>
<form method=get name=myform>
<select name=person>
<option value=jfk> John F. Kennedy
<option value=mlk> Martin Luther King
</select>
<input type=hidden name=personindex>
<input type=hidden name=personlabel>
<input value=Submit type=Submit
onClick='
var vForm =document.myform; // the form
var vSelect =vForm.person; // the select-one box
var vIndex =vSelect.selectedIndex; // the array index of select-one
var vOption =vSelect.options[vIndex]; // the selected option object
vForm.personindex.value=vIndex; // set the hidden text field
vForm.personlabel.value=vOption.text; // set the hidden text field
'>
</form></body></html>
---------------------------------------------------------------
<html><body>
<script>
function selecthelp (vForm) {
var i, vIndex, vSelect, vOption;
for (i=0; i < vForm.elements.length; i++) {
vSelect=vForm.elements[i]
if (vSelect.type=="select-one") {
vIndex=vSelect.selectedIndex;
vOption=vSelect.options[vIndex];
// We require our HTML authors to have every select-one box
// followed immediate by the hidden fields for index and label.
// If we wanted to bulletproof, we could reference by name, etc.
vForm.elements[i+1].value=vIndex;
vForm.elements[i+2].value=vOption.text;
}
}
}
</script>
<form method=get name=myform>
<select name=person>
<option value=jfk> John F. Kennedy
<option value=mlk> Martin Luther King
</select>
<input type=hidden name=personindex>
<input type=hidden name=personlabel>
<input value=Submit type=Submit onClick="selecthelp(document.myform)">
</form></body></html>
_________________________________________________________________________
For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
For dire need help, email: [EMAIL PROTECTED]