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 :: how to check if username already exists in database using javascript 
Javascript :: react event listener 
Javascript :: capitalize first letter of a string 
Javascript :: how to global a variable in javascript 
Javascript :: update node two versions mac 
Javascript :: You are trying to create a styled element with an undefined component.You may have forgotten to import it. 
Javascript :: getSheetByName 
Javascript :: feet to inches 
Javascript :: formdata 
Javascript :: react final form 
Javascript :: check if refresh token expired redirect 
Javascript :: how to coerce a string to number in javascript 
Javascript :: javascript how-do-i-check-whether-a-checkbox-is-checked-in-jquery 
Javascript :: a function that returns a string javascript 
Javascript :: arguments object in javascript 
Javascript :: javascript canvas 
Javascript :: hide and open jquery 
Javascript :: form status angular 
Javascript :: javascript for loop 
Javascript :: javascript bounce animation 
Javascript :: how to flatten array in javascript using foreach loop 
Javascript :: vscode read environment variables 
Javascript :: get value from input by id in angular 
Javascript :: react render children inside parent component 
Javascript :: Import A Function From A Module In JavaScript 
Javascript :: coreui react change background color 
Javascript :: re init data vue js 
Javascript :: image and video lightbox react 
Javascript :: get the index of object in array 
Javascript :: javascript nested loop 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =