Check boxes on internal structured HTML forms

The following code is required to clear check boxes on internal structured HTML forms. If it isn't present in the script section, when you clear a check box and try to save an internal form, the field data will not be updated.

Copy
function handleHiddenField(name, checked)
{
     var hdn = document.getElementsByName(name);
     for (var i = 0; i < hdn.length; i++) {
          if (hdn[i].type == 'hidden' && checked) {
                hdn[i].disabled = true;
                return true;
                }
                else {
                    hdn[i].value = "off";
                    return true;
                }
            }
        }
        function PrepareCheckbox()
        {
            var items = document.getElementsByTagName('input');
            var data  = [];

            for (var i = 0; i < items.length; i++) {
                if (items[i].type == 'checkbox') {
                    handleHiddenField(items[i].name, items[i].checked);
                }
            }
}

Note: Ensure the PrepareCheckbox() function is called when the Submit button is pressed.