Latest news
Home » Others » Get selected value of dropdownlist or select box using JavaScript

Get selected value of dropdownlist or select box using JavaScript

For get Selected  option of select box use the “ e.options[e.selectedIndex].value”  in javascript.

 

Example

<select name=”jobrole” id=”jobrole” class=”text2″ style=””>
<option value=””>Job Role</option>
<option value=”1″ >Technical</option>
</select>

<script>
var e = document.getElementById(‘jobrole’);
var jobroleId = e.options[e.selectedIndex].value;
if(!jobroleId || jobroleId == ‘0’) {
alert(‘Select one job role’);
}else {
document.frmabtdubai.jobroleflag.value = jobroleId;
document.frmabtdubai.submit();
}

</script>

Leave a Reply

x

Check Also

AB de Villiers made fastest Century in Cricket History 2015

AB de Villiers made fastest Century in world cup Cricket History 2015