Get Selected Value


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <form name=form0>
  2. <select name="selectFormName" onchange=getValueSelected()>
  3. <option value="Test A">Test A</option>
  4. <option value="Test B">Test B</option>
  5. <option value="Test C">Test C</option>
  6. </select>
  7. </form>
  8. <br/><br/>
  9.  
  10. <script>
  11. function getValueSelected(){
  12. var x = document.form0.selectFormName.selectedIndex;
  13. alert(document.form0.selectFormName.options[x].value);
  14. };
  15. </script

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.