[thelist] Javascript if...or statement

Stephen Caudill SCaudill at municode.com
Fri Aug 30 14:13:01 CDT 2002


Gurgle... gurgle... attempting to compile.  Ermm... guess I need to go back to DOM basics.  Thanks for the point in the right direction.


Stephen Caudill
Web Designer
Municipal Code Corporation
www.municode.com
www.mccimaging.com


-----Original Message-----
From: Joshua Olson [mailto:joshua at waetech.com]
Sent: Friday, August 30, 2002 1:48 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] Javascript if...or statement


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

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !



More information about the thelist mailing list