Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to know if select input has been selected in 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

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #select #input #selected #js
ADD COMMENT
Topic
Name
9+7 =