View Single Post
  #4 (permalink)  
Old April 30th, 2005, 11:30 AM
interrupt interrupt is offline
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should also be able to have a function 'per item selected' using the selectedIndex method. So you'd have a function called by the onchange event, then depending on the selection made, another function being called.

ie:

<form name ="form1">
<select name ="sel1" onchange ="myFunction()">
<option value ="0">0
<option value ="1">1
<option value ="2">2
</option>
</select>

<script language ="javascript">
function myfunction(){
var theSelection = document.form1.sel1.selectedIndex

if (theSelection ==0){
function0()
}
elseif (theSelection ==1){
function1()
}
elseif (theSelection ==2){
function2()
}
}
function0(){
alert("I was called from function 0")
}
function1(){
alert("I was called from function 1")
}
function2(){
alert("I was called from function 2")
}

</script>

Hope that helps! (Haven't tested yet, but it looks ok)

interrupt


Reply With Quote