I know that this might be very simple question and I tried to find solutions in the web but I can't figure it... I have the following C# / ASPX code: SelectArea += '
Solution 1:
For example if you have
<select id ="myselect" > <option value ="1" > value1</option > <option value ="2" selected ="selected" > value2</option > <option value ="3" > value3</option > </select >
Copy To get selected option do:
var selects = document .getElementById ("myselect" );
var selectedValue = selects.options [selects.selectedIndex ].value ;var selectedText = selects.options [selects.selectedIndex ].text ;
Copy Sample JsFiddle
Solution 2:
Try with this
var el = document .getElementById ("area" );
var selectedArea = el.options [el.selectedIndex ].value ;
Copy Solution 3:
Try :
var myList = document .getElementById ("area" );
var selectedValue = myList.options [myList.selectedIndex ].value ;
var selectedText = myList.options [myList.selectedIndex ].text ;
Copy
Post a Comment for "Get Value From Select List In Js"