How To Get The Value Of A Selected Text In Javascript
Possible Duplicate: How to get the selected value of dropdownlist using JavaScript? I have a select:
Solution 1:
document.getElementById('short_code').value
Solution 2:
This should do it:
<scripttype="text/javascript">functiongetSelected(select) {
alert(select.options[select.selectedIndex].value);
}
</script><selectid="short_code"onchange="getSelected(this)"><optionvalue="12">First</option><optionvalue="11">Second</option><optionvalue="10">Third</option><optionvalue="9">Fourth</option></select>
Solution 3:
document.getElementById('short_code').options[document.getElementById('short_code').selectedIndex].text
Solution 4:
Try this:
var el = document.getElementById("short_code");
var code = el.options[el.selectedIndex].value;
Post a Comment for "How To Get The Value Of A Selected Text In Javascript"