[Home] [By Thread] [By Date] [Recent Entries]

  • To: "Xml-Dev (E-mail)" <xml-dev@l...>
  • Subject: trying to get the text of a select box in reusable function
  • From: "Rochester, Dean" <Dean.Rochester@P...>
  • Date: Fri, 1 Mar 2002 11:45:53 -0500

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;
}

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member