html get selected option javascript
var e = document.getElementById("selectElementID");
var value=e.selectElement.options[e.selectedIndex].value;// get selected option value
var text=e.options[e.selectedIndex].text;//get the selected option textvar e = document.getElementById("elementId");
var value = e.options[e.selectedIndex].value;
var text = e.options[e.selectedIndex].text;<select id="ddlViewBy">
<option value="1">test1</option>
<option value="2" selected="selected">test2</option>
<option value="3">test3</option>
</select>
<script>
var e = document.getElementById("ddlViewBy");
var strUser = e.value; // 2
var strUser = e.options[e.selectedIndex].text; //test2
</script>
Also in JavaScript:
- javascript class setter
- javascript find document body
- how to enter a line of javascript code in vscode without having to arrow out of parenthesis to add a semicolon
- moment format datetime postgresql
- jquery visible
- column gap without affecting width site:stackoverflow.com
- react native passing params to nested navigators
- javascript parseint string with comma
- react pass prop to parent
- integers to space separated string in javascript
- 14. Write a JavaScript function to find the difference of two arrays. Test Data : console.log(difference([1, 2, 3], [100, 2, 1, 10])); ["3", "10", "100"]
- round down js
- how to shorten conditional statements javascript
- node.js server
- sort array based on another array
- Node require module
- javascript find duplicate in array
- Property 'find' does not exist on type NodeListOf
- javascript echo
- async await anonymous function
- reduce method in javascript array of bjects
- copy object array javascript
- Javascript format to currency
- react map