actually document.blah.formname.value was returning the value of the
selected index fine..
nice explantion though thanks


----- Original Message -----
From: "Charlie Griefer" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, May 30, 2003 11:14 PM
Subject: RE: js question


> -----Original Message-----
> From: Ewok [mailto:[EMAIL PROTECTED]
> Sent: Saturday, May 31, 2003 1:42 AM
> To: CF-Talk
> Subject: OT: js question
>
> >> im trying to get the displayed text from a select field (not the value)
> >>
> >> <select name="blah" size="1">
> >> <option value="1">Option One</option>
> >> </select>
> >>
> >> I know document.formname.blah.value would return "1", is there a way to
> >> return "Option One" when that option is selected?
>
> Actually document.formname.blah.value would explode.  That's the correct
> syntax to obtain a text field (or textarea) value.  Select boxes are
> different, as they contain an array of options.
>
> document.formname.blah.options[document.formname.blah.selectedIndex].value
> <-- value
> document.formname.blah.options[document.formname.blah.selectedIndex].value
> <-- text
>
> Just to explain that a bit...
> options (as mentioned above) is an array, so you need to reference a
> particular option using array notation.  The position (inside the []) is
> obtained using selectedIndex, which specifies which option is currently
> selected.
>
> so if item 0 is selected (selectedIndex = 0), the statement evaluates to:
> document.formname.options[0].text
> document.formname.options[0].value
>
> hth,
> charlie
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to