Get Value From Select List In Js October 23, 2024 Post a Comment 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 <selectid="myselect"><optionvalue="1">value1</option><optionvalue="2"selected="selected">value2</option><optionvalue="3">value3</option></select>CopyTo get selected option do:var selects = document.getElementById("myselect"); var selectedValue = selects.options[selects.selectedIndex].value;// will gives u 2var selectedText = selects.options[selects.selectedIndex].text;// gives u value2CopySample JsFiddleSolution 2: Try with thisvar el = document.getElementById("area"); var selectedArea = el.options[el.selectedIndex].value; CopySolution 3: Try :var myList = document.getElementById("area"); var selectedValue = myList.options[myList.selectedIndex].value; var selectedText = myList.options[myList.selectedIndex].text; Copy Share Post a Comment for "Get Value From Select List In Js"
Post a Comment for "Get Value From Select List In Js"