Extracting the current value of a DOM element

So, say I have two select boxes. One with the letters of the alphabet,
and a second with a list of names. When I select the letter in the
first, how do I, in my onChange function, extract the value I selected
in the first box, to determine what values to populate the second box
with?

I don’t want to submit the form, I’d like to do this with Ajax.

Thanks in advance,
Ben.

Ben Brightwell wrote:

So, say I have two select boxes. One with the letters of the alphabet,
and a second with a list of names. When I select the letter in the
first, how do I, in my onChange function, extract the value I selected
in the first box, to determine what values to populate the second box
with?

I don’t want to submit the form, I’d like to do this with Ajax.

Thanks in advance,
Ben.

A B

completely untested, but you get the idea. You first need a reference to
the select element. Then the selectedIndex property will give you the
index of the selected option and the options property is an array of the
options.

Dana P

Dana Pieluszczak wrote:

A B

completely untested, but you get the idea. You first need a reference to
the select element. Then the selectedIndex property will give you the
index of the selected option and the options property is an array of the
options.

Dana P
Ok, that works for a static example, but what if I want to send the
value to the controller? I can’t figure out how to take the ‘this’
object and translate it to ruby code.