[thelist] Javascript - detecting which SELECT!
Steve Cook
sck at biljettpoolen.se
Tue Dec 5 04:08:01 CST 2000
Hi folks,
I'm writing an aplication that uses a number of select elements on a page.
Selecting a value in one should fire up a JavaScript function that redirects
to a new page, with the selected value included within a query string.
After reading 3 JavaScript tutorials, I'm most of the way there, but I'm
stuck on trying to detect which select I have clicked on!
I know that the actual element is found like this:
window.document.form_name.select_name.selectedIndex
returns the array number, you can then type
window.document.form_name.select_name.options[that_number].text
to find out what was actually selected
All well and good, but if I have multiple select elements on the page, how
do I detect "select_name" in the code above. I've tried:
window.document.form_name.elements.selectedElement
to detect the element (and various permutations of that). I've also tried
passing the info in my onChange like this:
onChange="leapTo(window.document.theForm.how.options[selectedIndex])"
Where "theForm" and "how" are set to the names I'm actually using in the
script.
The horrible thing is I'm sure this is terribly easy. Someone please
enlighten me :-)
.steve
(You'd never believe I once wrote an evolt article about a JavaScript
application I wrote! (http://evolt.org/index.cfm?menu=8&cid=567) I actually
really dislike JavaScript. I find it counterintuitive, the DOM quite frankly
scares me and I always end up feeling I have to sweat blood to make it do
the simplest thing :-/
----------------------------------
WapWarp - http://wapwarp.com
Wap-Dev - http://www.wap-dev.net
Cookstour - http://cookstour.org
----------------------------------
More information about the thelist
mailing list