Monday 12 May 2008

HTML Check Boxes values when Disabled by Javascript clear themselves when saved

Caught this one today.

You have a check box on a form
For one reason or another you use the JS
document.forms[0].myCheckBox.disabled = true;
to stop users changing it on the form.

However if you then SAVE the form back to the Domino server with the disabled status of the field still set to TRUE. Any values the checkbox had will disappear and the field will saved as empty!

This does not happen with RADIO , TEXT and TEXTAREA elements. The only affected one appears to be CHECKBOX. I came across this because I was using AJAX to go back to the server to get some information and based on that one of three sets of CheckBoxes would become available the other 2 would be set to fixed values and then disabled to stop the user breaking the logic.

Simply puting an onSubmit functions that turns the CHECKBOXes Disabled status back to FALSE prevents this from happening.

Disqus for Domi-No-Yes-Maybe