← Prev in month ← Prev in thread
Next in thread → Next in month →

trying to get the text of a select box in reusable function

From
Rochester, Dean <>
To
"Xml-Dev (E-mail)" <>
Date
2002-03-01T16:45:53Z
ID
<>
Thread
trying to get the text of a select box in reusable function
Hi

I am trying to write a reusable function that I can use to get the text of a
select object.  I do not know the name of the select, I am walking through a
form.

Here is what I have tried.  It does not like the use of the 

toString(elements[intLoop].getAttribute('name'))

in the last line.


strField = elements[intLoop].getAttribute('value');  
// if the field is a select box the value from the line above will
// be null even if there is a value in the box.
// you need the option selected value for the strField variable
if (strField == null || strField == "") {
     var OptionsList =
document.forms[0].toString(elements[intLoop].getAttribute('name'));
     strField =
document.forms[0].toString(document.forms[0].getAttribute('name')).options[O
ptionsList.selectedIndex].text;
}
← Prev in month ← Prev in thread
Next in thread → Next in month →