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 element

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

get selection value javascript

var e = document.getElementById("ddlViewBy");
var strUser = e.value;
Comment

get selected option from select javascript

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

PREVIOUS NEXT
Code Example
Javascript :: parse time in javascript 
Javascript :: javascript ready state 
Javascript :: floating button react 
Javascript :: javascript remove query string from url 
Javascript :: string normalize javascript 
Javascript :: javascript html append 
Javascript :: socket io emit to socket id 
Javascript :: javascript convert string with square brackets to array 
Javascript :: functional component how to add to existing array react 
Javascript :: how to use axios get 
Javascript :: add checkbox dynamically in javascript 
Javascript :: node js on macbook m1 
Javascript :: jszip angular 
Javascript :: react usereducer 
Javascript :: inline styling in react 
Javascript :: jquery select option by value 
Javascript :: regex usage 
Javascript :: how to check password and confirm passwor in joi 
Javascript :: how to repeat an array of objects n times in javascript 
Javascript :: react native float upto 2 digits 
Javascript :: angular print json 
Javascript :: using fetch api 
Javascript :: angular material remove outline 
Javascript :: javascript slice array 
Javascript :: array iteration 
Javascript :: how to disable and enable a button in jquery 
Javascript :: grepper extension firefox 
Javascript :: js copy paragraph onclick 
Javascript :: codeblocks in html cdnjs 
Javascript :: falsy values javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =