I have a form. One top of the form I have a checkbox. It is unchecked by default and the rest of the form fields are disabled. When Checkbox is checked the form fields become editable.
I started writing function but it uses field names and becomes too long and bulky
PHP Code:
function disableForm() {
if (document.myForm.myCheckbox.checked == true) {
document.myForm.Field1.disabled = false;
document.myForm.Field2.disabled = false;
document.myForm.Field2.disabled = false;
} else {
document.myForm.Field1.disabled = true;
document.myForm.Field2.disabled = true;
document.myForm.Field2.disabled = true;
}
}
Isn't there a way I can add an ID to the fields that I wish to disable on load and then call that ID instead of writing two statements for each field?
There are form fields that should not be affected by this checkbox too.
Bookmarks