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 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 :: js contains 
Javascript :: image file upload in angular 
Javascript :: JSON.stringify() function converts buffers into objects. The raw data is encoded as an array of bytes that you can pass in to Buffer.from(). 
Javascript :: emergency food meme 
Javascript :: three ways of writing a function in javascript 
Javascript :: start nodemon under wsl2 
Javascript :: launch json for golang with args 
Javascript :: js.l2 
Javascript :: how to print elements in an array in javascript 
Javascript :: react hook form submit outside form 
Javascript :: return then javascript 
Javascript :: sitecore rendering paramaters get 
Javascript :: loop through elements by name js 
Javascript :: if operator ternary 
Javascript :: add pdf in react app 
Javascript :: new features of angular 11 
Javascript :: esbuild 
Javascript :: vue router Async Scrolling 
Javascript :: get date in format 
Javascript :: javascript how to convert string to number 
Javascript :: Fetch Data Using Getx 
Javascript :: addeventlistener javascript multiple functions 
Javascript :: codeceptjs "waitForClickable" 
Javascript :: dotenv in node js 
Javascript :: get field type file js and loop 
Javascript :: slice string javascript 
Javascript :: cypress/react yarn 
Javascript :: JavaScript Creating Symbol 
Javascript :: camel case first javascript 
Javascript :: javascript access pushed element 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =