Reputation: 3546
I have a classic HTML select box:
Show:
<select name="show" id="showThreads">
<option value="all" selected="selected">All</option>
<option value="new">Only unread</option>
</select>
Now, I need JavaScript to make an Ajax request when the user changes the selection in the box (without jQuery). I have tried:
<option>
tags, but it won't work for users using a keyboard or a touch device<option>
tags and checking if the selected one changes, but it seemed to trigger even when I simply hovered over the second option.Is there a way of doing this that will work on all browsers/devices? Thanks!
Upvotes: 0
Views: 61
Reputation: 1987
function yourAjaxCall(something) {
}
<select name="choice1" size="1" onchange="yourAjaxCall(this);">
<option value="one">first</option>
<option value="two">second</option>
<option value="three">third</option>
</select>
Upvotes: 0
Reputation: 140236
Try the "change"
event.
document.getElementById("showThreads").onchange = function() {
};
Upvotes: 3