Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js get option value

<select id="ddlViewBy">
  <option value="1">test1</option>
  <option value="2" selected="selected">test2</option>
  <option value="3">test3</option>
</select>

var e = document.getElementById("ddlViewBy");
var strUser = e.value;
//Would make strUser be 2.

var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].text;
//Would make strUser be test2.
Comment

find option values using javascript

var thisOptionValue = [];
    $("#age option").each(function() {
        thisOptionValue.push($(this).val());

    });
    console.log(thisOptionValue)
Comment

PREVIOUS NEXT
Code Example
Javascript :: vue v-for object 
Javascript :: js form serialize 
Javascript :: file upload with angular material 
Javascript :: vue dynamic component props 
Javascript :: How to calc() height in react native for styling 
Javascript :: check undefined in javascript 
Javascript :: how-to-save-array in Local storage - js 
Javascript :: react native scrollable 
Javascript :: js listen for class change event 
Javascript :: get an html img tag from a string 
Javascript :: json to csv nodejs 
Javascript :: javascript get first property of object 
Javascript :: validate zip code javascript 
Javascript :: nodejs mysql connection pool 
Javascript :: scroll element by javascript 
Javascript :: javascript insert item into array 
Javascript :: angular load json file with httpclient 
Javascript :: javascript find 
Javascript :: replace all occurrences of a string in javascript 
Javascript :: truncate a string 
Javascript :: javascript button 
Javascript :: install react router 
Javascript :: mongoose query if field exists where filed exists 
Javascript :: how to wait a determined amount of time before doing something in js 
Javascript :: mongoose delete property 
Javascript :: send data from one page to another html page in Javascript 
Javascript :: Reading Time with jquery 
Javascript :: button in javascript 
Javascript :: make event nodejs 
Javascript :: discordjs eval 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =