Return the text of the selected option in a drop-down list:
var x = selTag.options[selTag.selectedIndex].text;
<!DOCTYPE html> <html> <body> Select your favorite: <select onchange="myFunction(this)"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> </select>/*from w w w .j a v a 2 s. c om*/ <p id="demo"></p> <script> function myFunction(selTag) { var x = selTag.options[selTag.selectedIndex].text; document.getElementById("demo").innerHTML = "You selected: " + x; } </script> </body> </html>