Mega Code Archive

 
Categories / JavaScript DHTML / Form Control
 

Show Selected Option items

<html> <head> <script language="JavaScript"> <!--   function showSelected(f) {   var selNum  = f.planets.selectedIndex;   var selText = f.planets.options[selNum].text   alert("Selection option selected: " + selNum + " " +"Selection option text: " + selText);  } //--> </script> </head> <body> <form name="mySelection"> Where <i>do</i> the Aliens exist? <select name="planets"> <option>AA <option selected>BB <option>CC </select> <p> <input type="button" value="See selection" onClick="showSelected(this.form)"> </form> </body> </html>