In CRM 2011, it was found that the checkbox is not working as per our expectation. As we all know, the twooptionset(bit field) attribute type is converted to a checkbox on the form. Now consider a scenario. When you tick or untick the checkbox we would like to execute some code (Say hide a control). But the code written in Onchange is not fired until we leave the checkbox. So if we click outside of checkbox or if we press tab button, then only code changes would reflect. Whereas our expectation is always an immediate change when we tick or untick the checkbox. The following workaround could be applied to the checkbox. This code could be written in any event which is prior to Onchange event of the checkbox. So obviously we should prefer OnLoad event of the form in most of the cases.
crmForm.all.yourattributename.onclick = function () {
crmForm.all.yourattributename.FireOnChange();
};
Eg: If you have a checkbox called new_mycheckbox then
In Page Load (OR any event which happens before Onchange of checkobx) write this code
crmForm.all.new_mycheckbox.onclick = function () {
crmForm.all.new_mycheckbox.FireOnChange();
};
and then write the code (hide control or whatever ...) in OnChange event of checkbox
Hi..
ReplyDeleteDid this work for anyone ? I think there is no onclick event for a radio button/check box...so this solution is not working for me.
any help would be greatful.
worked perfectly for me. Just add a function with the line of code for each checkbox and then trigger that function on the form onload event. After that, the checkboxes triggered immediately when checked or unchecked.
ReplyDeleteGreat tip. thanks.
Try this:
ReplyDelete1. include jQuery library to the form
2. OnLoad, attach the On Click event:
$('#new_checkbox').click(FunctionCheckboxOnClickHanlder);
Cheers,
Taj