0 votes
1 view
in Web Technology by (22.4k points)

I've got a load of checkboxes that are checked by default. My users will probably uncheck a few (if any) of the checkboxes and leave the rest checked.

Is there any way to make the form POST the checkboxes that are not checked, rather than the ones that are checked?

1 Answer

0 votes
by (40.3k points)

You can try adding a hidden input for the checkbox with a different ID like this:

<input id='testName' type='checkbox' value='Yes' name='testName'>

<input id='testNameHidden' type='hidden' value='No' name='testName'>

But, before submitting the form you can just disable the hidden input based on the checked condition this way:

if(document.getElementById("testName").checked) {

    document.getElementById('testNameHidden').disabled = true;

}

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...