Previously I wrote a
post to tell how to use onClick event in CRM 4.0 for checkboxes. Recently I felt it is not completed. I think, it’s a matter of usability engineering expectations. You can simply use either onChange or onClick for checkboxes.
Will check onChange;
You can simply double click the field in customization form view and see the event. Then you know how to add the script in the relevant box and enable it. It’s as simple as that.
For example put below alert statement to check the firing of the event.
alert("onChange event fired");
Now if you browse the form after publishing... try to change the value of checkbox. What you will notice is you have to do two clicks to fire the event. You got to click the checkbox (nothing happens) and click somewhere else (to take the focus away) to confirm your change... then you can see the alert message pops up.
Will check onClick;
Here you are not touching anything in the relevant field... but write a method in the loading of the form as below.
Now if you browse the form and do the previous test here.. you will notice, once you click the checkbox alert triggers. This means you only need one click.
deliveryCheckbox();
deliveryCheckbox = function()
{
crmForm.all.msn_isDelivery.onclick = function()
{
alert("onClick event fired");
}
}
As a conclusion, I would suggest you to use onClick for all the cases, if there is no special reason to use onChange. My point is “not just saving one mouse click” our users are not always technical people. I have seen users just click the check box and try to save the form. If we have used a script to work for onChange event, it wouldn’t have happened in such cases.
Related Posts;
Issues of using checkbox in CRM 2011