[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SELECT values
if you just want the text after the <OPTION>some_text use
select_name.options[index].text == some_text
if you want the <OPTION VALUE="the_value"> i assume you use
select_name.options[index].value == the_value
but i am not sure for that one
to get the current select
var current_index = select_reference.options.selectedIndex
var current_choice = select_reference.options[current_index].text
Chris Moses wrote:
>
> O.K. guys, this is probably a stupid question but I just can't get the following
> script to work. I've checked the 411 FAQ, and the %$@ official documentation.
> All I want to do is return the value selected in the OPTION list in the alert window.
>
> By the way, I spent a good amount of time on 411. It is a very nice FAQ, good work
> Andy. I have a couple suggestions but I'll post them seperately.
>
> Obviously, I have stripped out the extraneous stuff:
>
> <SCRIPT LANGUAGE="JAVASCRIPT">
> function newtopic() {
> alert("Selected SubTopicID="+document.SubTopicID.value)<<I've tried
> every syntax I can think of with .value,
> .selectedIndex....
> }
> </SCRIPT>
>
> <FORM NAME="listform">
> <SELECT NAME="SubTopicID">
> <OPTION>Disk Drives
> <OPTION>Motherboards
> <OPTION>SCSI Controllers
> <OPTION>Memory
> </SELECT>
> <INPUT TYPE="button" VALUE="Reload" onClick="newtopic()">
> </FORM>
>
> Any help will be greatly appreciated.
> Chris Moses
> --------------------------------------------------------------------
> For help about the list, please send a message to 'majordomo@obscure.org'
> with the message body 'help'. To unsubscribe, send a message to
> 'majordomo@obscure.org' with the message body 'unsubscribe javascript'.
> List archives and pointer to FAQ: http://www.obscure.org/javascript/
--------------------------------------------------------------------
For help about the list, please send a message to 'majordomo@obscure.org'
with the message body 'help'. To unsubscribe, send a message to
'majordomo@obscure.org' with the message body 'unsubscribe javascript'.
List archives and pointer to FAQ: http://www.obscure.org/javascript/