Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

html get selected option javascript

<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>
Comment

js get selected option elemeng

var yourSelect = document.getElementById( "your-select-id" );
alert( yourSelect.options[ yourSelect.selectedIndex ].value )
Comment

get selected option from select javascript

const selectedValue = document.getElementById("color-id").value;
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery scrolltop animate 
Javascript :: regex for first three characters 
Javascript :: javascript check if two date are ugual 
Javascript :: javascript middle of array 
Javascript :: replace string shopify 
Javascript :: Use Recursion to Create a Countdown 
Javascript :: jquery insert option into select 
Javascript :: moment is not defined 
Javascript :: how to get current year in nodejs 
Javascript :: mac install jmeter 
Javascript :: string to int javascript 
Javascript :: module not found reactstrap 
Javascript :: electron specify minimum size 
Javascript :: function click anywhere javascript 
Javascript :: rxjs cdn 
Javascript :: hide status bar react native 
Javascript :: react set title of page 
Javascript :: javascript loop through array 
Javascript :: how send to another page by router in vuejs 
Javascript :: react native loading 
Javascript :: min object value in array 
Javascript :: how to update node modules 
Javascript :: convert binary to decimal javascript 
Javascript :: send message to all servers discord.js 
Javascript :: display block class javascript 
Javascript :: javascript document ready 
Javascript :: jquery set max attribute value 
Javascript :: how to format unix timestamp javascript 
Javascript :: javascript csv string with commas in fields 
Javascript :: array to string js 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =