-----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 Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4