[thelist] Javascript if...or statement

Joshua Olson joshua at waetech.com
Fri Aug 30 12:49:01 CDT 2002


----- Original Message -----
From: "Stephen Caudill" <SCaudill at municode.com>
Sent: Friday, August 30, 2002 1:23 PM


> At the risk of sounding more greenhorn than usual, what would I use in
place of the value property?

The cross platform way to get a value from a select box is as such:

form.elements.myselect.options[form.elements.myselect.options.selectedIndex]
.value

or likewise

temp = form.elements.myselect.options;
temp[temp.selectedIndex].value

You could write a function:

function selectValue(element)
{
  return element.options[element.options.selectedIndex].value;
}

Then, simply use:

selectValue(form.elements.myselect)

Uggg.



In some cases, if you know the value you want to is option number 1, then
you can use simply

form.elements.myselect.options.selectedIndex == 0

If that is true, then you know that the first item in the dropdown is
selected.

-joshua




More information about the thelist mailing list