Mega Code Archive

 
Categories / JavaScript DHTML / Form Control
 

Option selected index

<html> <head> <script language="JavaScript"> <!-- function selectChange() {    selIdx = document.forms[0].marsupials.selectedIndex;    newSel = document.forms[0].marsupials.options[selIdx].text;    alert("Selection has changed to: " + newSel); } //--> </script> </head> <body> <basefont size=4> <form> Please choose a city: <select name="marsupials" onChange="selectChange()"> <option>A <option>B <option>C </select> </form> </body> </html>