On our drop-down box is an "onChange" event..... sending us to the
"selectionMade()" function
<SELECT NAME = Select1 onChange = selectionMade()>
In the following code we use the "selectedIndex"
to get the value of which option was chosen
the + 1 is used because the "selectedIndex" in javascript starts at
zero, not at one to number the elements in our option list
<SCRIPT LANGUAGE = JavaScript>
function selectionMade()
{
document.form1.TextBox.value = "You chose selection " + (document.form1.Select1.selectedIndex
+ 1)
}
</SCRIPT>
{
var options_string = "";
var the_select = window.document.form2.list_1;
for (loop=0; loop < the_select.options.length; loop++)
{
if (the_select.options[loop].selected == true)
{
options_string += the_select.options[loop].text
+ " ";
// That += is supposed to concatenate onto the text, but doesn't -- just
so you see that it isn't working....
}
}
alert("you selected: " + options_string);
}
Once you know the index number of the selected option, you can find out what it is:Notice that the arrays are named the same thing as the animals in the array