So I just encountered a weird situation that checkbox is just stressing me out. I am trying to build a "milestone" function which looks like this:
[Browsing state][1] | [Edit state][2] [1]: http://ift.tt/2gIr6NO [2]: http://ift.tt/2gjFHv4
I use ms[]
here so I can pull all the items in back end using PHP POST.
<input type="text" class="form-control" name="ms[]" value="<?=$value["content"]?>">
The problem is that when I get these checkboxes using $_POST['ms[]']
, it actually just gives me an array of only the checked items. Then I can't really know which ones are unchecked by user.
I read through some popular solutions here and all of them seems to require the name attributes of my inputs to be different. But since the "milestone" is deletable and addable, I can't give it a unique name for each one.
I also came up with some other possible solutions like making all these checkboxes hidden textboxes. And every time user check or uncheck a checkbox, the corresponding textbox is set to '1' or '0'. But this requires me to revamp the whole thing.
I am just wondering if there is any easy and reliable way to get a complete list of the checkboxes no matter they are checked or not?
Thank you for your help in advance.
Aucun commentaire:
Enregistrer un commentaire