Introduction:
In my previous article I have explained about How
to replace a string in XSLT. In this article I am going to explain about how to get selected
items text using javascript
Explanation:
I
need to get the selected items text of a html select. For this below javascript
function is used.
<script>
function
getSelectedText(elementId) {
var elt
= document.getElementById(elementId);
if
(elt.selectedIndex == -1)
return
null;
return
elt.options[elt.selectedIndex].text;
}
</script>
Below is the
sample usage of the code.
var selText=getSelectedText('mySelect')
Now selText will contain the value of the selected
items text.
Do
you like this article? Help us to improve. Please post your comments below.
Comments
Post a Comment