How to get selected value from Dropdown list in JavaScript

前端 未结 6 954
無奈伤痛
無奈伤痛 2020-12-28 16:17

How can you get the selected value from drop down list using JavaScript? I have tried the following but it does not work.

var sel = document.getElementById(\         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 16:37

    I would say change var sv = sel.options[sel.selectedIndex].value; to var sv = sel.options[sel.selectedIndex].text;

    It worked for me. Directing you to where I found my solution Getting the selected value dropdown jstl

提交回复
热议问题