0

evening... I want to know which node or value is selected from the drop down menu ( select tag) when I click apply... i dont seem to refer to them correctly.. please help!

<script type="text/javascript">
function apply(){
var xy = document.getElementById("hmm").childNodes;
var ab = xy.value;
alert(ab);
}
</script>
</head>


<body>
<div id="unique">
<select id="hmm" name="drop">
<option value="" id="text area">Text Area</option>
<option value="" id="paragraph">Paragraph</option>
<option value="" id="radio">Radio Button</option>
<option value="" id="delete">Delete</option>
</select>
<button id="apply" onclick="apply()">Apply</button> 
</div>
</html>
  • 1
    possible duplicate of [How to get the selected value of dropdownlist using JavaScript?](http://stackoverflow.com/questions/1085801/how-to-get-the-selected-value-of-dropdownlist-using-javascript) – zzzzBov Mar 18 '14 at 19:10
  • That was helpful as well @zzzzBov Thanks!! :) –  Mar 18 '14 at 19:20

1 Answers1

0
function apply() {
    var selectBox = document.getElementById("hmm");
    var selectedOption = selectBox.options[selectBox.options.selectedIndex];
    alert(selectedOption.value);
}

Working Fiddle

El Guapo
  • 5,581
  • 7
  • 54
  • 82