<input class="jProblemClass" id="Checkbox{%= ID %}" type="checkbox" onchange="problemPicker.onChangeProblemCheckBox('{%=ID %}');"/>
After first check or uncheck nothing happens. Afetr second click, call my function problemPicker.onChangeProblemCheckBox
, but i get ID first check. Why? Can help me anybody?
onChangeProblemCheckBox: function(id) {
if ($('#CheckBox' + id).attr("checked") == true) {
problemPicker.addToCheckProblems(id);
var checkboxes = $('.jProblemClass:checked');
if ((checkboxes.length > general.limit) && (general.limit != 0)) {
alert('The limit of ' + general.limit + ' problems exceeded. Please deselect ' + (checkboxes.length - general.limit).toString() + '.');
}
} else {
problemPicker.delFromCheckProblems(id);
}
},
Bro use onclick event instead onchange.. Reason... According to the Javascript references I've read, onchange fires after the focus is lost. Unless you click somewhere else, the focus is not lost in IE. The other browsers must not be waiting for the focus to be lost before firing onchange - which suggest they are not following the spec correctly (despite it making more sense to fire at that point). How about using onclick and onkeydown/onkeyup instead (by using both onclick and onkeyup/onkeydown you cover both mouse and keyboard setting of the checkbox). REFERENCE : http://www.winvistatips.com/re-onchange-event-checkbox-not-working-properly-t311364.html