Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to check if an item is selected from an HTML drop down list with javascript js

// See the below HTML first
/*
<select id="cardtype" name="cards">
    <option value="mastercard">Mastercard</option>
    <option value="maestro">Maestro</option>
    <option value="visadebit">Visa Debit</option>
</select>
*/

// Javascript Solution
var select = document.getElementById("cardtype");
var selectedValue = select.options[select.selectedIndex].value;

// Courtesy: Sachin - https://stackoverflow.com/users/1041642/sachin

Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript object instead of switch 
Javascript :: Conditionallu inline styling in react 
Javascript :: Extract the domain name from a URL 
Javascript :: how to make your own drop down react native 
Javascript :: use svg image in next js 
Javascript :: github pages react route 
Javascript :: vue 3 router redirect 
Javascript :: redirect to download javascript 
Javascript :: jquery datatable table header not increasing on expanding 
Javascript :: js random number between 1 and 5 
Javascript :: how to use filter in typescript 
Javascript :: Rounding Up To The Nearest Hundred js 
Javascript :: use effect react 
Javascript :: par ou impar js 
Javascript :: react native pm ERR! code EINTEGRITY 
Javascript :: how to add data to array in javascript dynamically 
Javascript :: Lodash.chunk chunk 
Javascript :: tsconfig build only files and not src 
Javascript :: jquery loop 0 to 10 
Javascript :: async await promise all javascript 
Javascript :: min heap javascript 
Javascript :: javascript foreach url parameter 
Javascript :: react native password 
Javascript :: innertext javascript 
Javascript :: expo app loading 
Javascript :: create react without jsx 
Javascript :: moment localization 
Javascript :: fatorial recursivo em javascript 
Javascript :: json in listview flutter 
Javascript :: if keypress javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =