Can I please have some help to call a Javascript function (getSelectedFilterText) when an Item is selected in a DropDownList.
Here is my code:
<select id="FeedBackFilter" name="FeedBackFilter" width="2000" onclick="getSelectedFilterText">
<option value="All">All</option>
<option value="Bad">Bad</option>
<option value="Good">Good</option>
<option value="Both">Both</option>
</select>
function getSelectedFilterText()
{
alert("test");
var e = document.getElementById("FeedBackFilter");
var strUser = e.options[e.selectedIndex].text;
alert(strUser);
}
What am I doing wrong?
First you need parentheses like so:
But if you’re only wanting it to happen when they change the selection, you should consider instead using the event ‘onchange’ like so:
This way it’ll happen when they change the option, not when they click it … which is different, they could click it without changing the option