I have a page with a set of checkboxes that I want to run the javascript function when a change occurs (I did something very similar with a drop down list - and it worked)
However, using the checkbox I have three problems:
my onChange event only fires “sometimes” (you need to change the focus between the various checkbox elements
when it starts, the result of the previous flag is returned (and not just the one that was clicked)
jQuery always returns true
Create Flags
<%= Html.CheckBox("sl-" + row.Id, value, new { onChange = "SuitabilityChecked("+row.Id+", "+key+")"})%>
Javascript
function SuitabilityChecked(providerId, parentRecordId) {
var params = {};
params.providerId = providerId;
params.parentRecordId = parentRecordId;
var value = $("#sl-" + providerId).val();
params.value = value;
$.getJSON("SuitabilityChecked", params, null);
};
source
share