PDA

View Full Version : Drop down menu that alerts its on value...problem?


vkidv
12-06-2003, 07:09 PM
i made a stupid script, but it worked until i needed more drop down menus:

what it does, is when you change the box, DropDown1. it alerts the value of the option..



<script>
function dome()
{
alertTEXT = document.form2.DropDown1.options.value
alert(alertTEXT)
}
</script>



extremely simple, i had a drop down box with an Onchange event which went straight to the function dome()
for example:

<option value="Message to be alerted">Subject</option>


I want to make more drop downs, but not call them different names?
Do i really need to use functions?

When i make a copy of DropDown1 i get an error when i use it, This is because there is two DropDown1s...

I dont want to keep making copies and renaming it to DropDown2, DropDown3 and so on.

I want to make it so i only have 1 script which makes them all work.

Im pretty sure i can make this work with the 'this' thing?
Ive seen it in many other scripts and it goes 'this. somthing'

Can somebody tell me how to do 'this' or any other method ?

thanks

A1ien51
12-06-2003, 08:15 PM
function dome(X)
{
alertTEXT = X.options.value
alert(alertTEXT)
}
</script>

onchange="dome(this)"


try that