Home > DeveloperSection > Forums > Getting the text from a drop-down box
john rob

Total Post:108

Points:756
Posted on    February-14-2013 2:03 AM

 JavaScript JavaScript 
Ratings:


 1 Reply(s)
 1002  View(s)
Rate this:

Hi MindStickians!

This gets the value of whatever is selected in my dropdown menu.

document.getElementById('newSkill').value

For those not sure, here's the HTML for a drop down box.

<select name="newSkill" id="newSkill">
    <option value="1">A skill</option>
    <option value="2">Another skill</option>
    <option value="3">Yet another skill</option>
</select>

Thanks in advance



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    February-16-2013 3:54 AM

Hi John!

For getting the text from a drop-down box as below

var skillsSelect = document.getElementById("newSkill");
var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;


Don't want to miss updates? Please click the below button!

Follow MindStick