Select The Same Option Multiple Times / Onchange Without Changing
Solution 1:
Contrary to some of the current answers, you don't actually get a click
event on <option>
in IE.
The only reliable way to detect the case of an option being clicked that was already selected is to put the onclick
handler on the <select>
. Naturally this will also detect any other clicks on the select element, so depending on what functionOne()
is doing this may not be safe either.
You might be better off with something that looks like a select but isn't, such as a pop-up div with buttons on it. What is it you are trying to do? If you're trying to do a “jump menu” where selecting an option navigates to a new page: don't, it's an old and discredited mechanism with serious usability problems.
Solution 2:
add onClick to the <option>
tag
Solution 3:
after firing the onSelect, change the select value to "Add Another"?
eg. forst option has an id of #selectBox, value of '' and a html of "Select One".
onChange, retrieve the value $('#selectBox').val();
and turn around after your actions and go $('#selectBox').val('').html('Select Another');
Solution 4:
Add an onclick
even to each option tag. Inside the function do:
function() {
var timesClicked = $(this).attr('times-clicked') || 0;
$(this).attr('times-clicked', ++timesClicked);
if (timesClicked == 1) {
functionONe();
}
elseif (timesClicked == 2) {
functionTwo(); // and so on
}
}
Post a Comment for "Select The Same Option Multiple Times / Onchange Without Changing"