Header menu


Tuesday, 6 May 2014

How to get value of select box in Javascript/Jquery ?


Get value of select box in Javascript/Jquery

This is my select box.  And i want to get its value in javascript/jquery .

<select name="qt" class="qt" id='qt'>
<option value='0'>&nbsp;</option>
<option value='Newspaper'>Newspaper</option>
<option value='Facebook Ad'>Facebook Ad</option>
<option value='Google Search'>Google Search</option>
<option value='Other Internet Site'>Other Internet Site</option>
<option value='Test Prep Center'>Test Prep Center</option>

 To get its value i will use two lines.

var s = document.getElementById('qt');         /**qt is the id of select box**/
var selectval = s.options[s.selectedIndex].value; 

Working example: