lundi 24 octobre 2022

Send unchecked checkboxes but with array

I have an input of checkboxes as an array:

<input type="checkbox" name="checkbox[]">

And I want to send the unchecked checkboxes as well. So if it's unchecked I want it to be in the array as well

I tried the solution in this post: POST unchecked HTML checkboxes:

  <input type='hidden' name='checkbox[]'>
  <input type='checkbox' name='checkbox[]'>

However, in the post it's not an array of checkboxes. In my case it doesn't work, it just adds it to the array and not overriding it.

So if I have a list of 5 checkboxes where 2 of them has been checked, I'll end up with 7 total of POST parameters (5 from the hidden, and 2 from the checkbox)




Aucun commentaire:

Enregistrer un commentaire