Hey I'm trying to create a checkable option for whether to make a file downloadable or not:
<input type='checkbox' id='dTAG' name='dTAG[]' value='true'>
I have JS appending new checkboxes once the user chooses they want to add a file:
udInput = document.createElement('input');
udInput.setAttribute('type', 'checkbox');
udInput.setAttribute('name', 'dTAG[]');
udInput.setAttribute('value', 'true');
This all works ^, but my problem is when taken to PHP, it will only store the values of those true, and not all values. I've tested this by:
echo count($_POST['dTAG']);
and where as say a user has uploaded 3 files, checked 2 but left 1 checkbox unchecked.. the value returned for
echo count($_POST['dTAG']);
is:
2 // not of 3 total checkboxes.
how do I get it to account for ALL checkbox values? whether it returns exactly false when unchecked doesn't matter as much.. I mostly just need the proper count of checkboxes, both checked and unchecked.
UPDATE: I got it working using Alan's method, thanks man!