I got a loop of checkboxes. I put a hidden field inside with different value and different id:
<form>
<?php
for($y=0;$y<$len;$y++)
{
echo "<div class='proc'> <pre>";
echo "<h6 >Process: ".$proc[$y]." " ;
echo "People required: ".$num[$y].". ";
echo "<span class='assigned' name='assigned[]' >People Assigned: 0. </span> <input id='unchecked' type='hidden' name='link[]' value='0'/><input id='checked' type='checkbox' name='link[]' value='1'><i title='Activate Process' class='fi-link'></i>Link Process</input></h6></pre>";
?>
<div class="procLeader">
<label>Leader:</label>
<ol>
<li class="placeholder"><div class="adding">Drop Here</div></li>
</ol>
</div>
<?php
echo "</div>";
}
?>
<input type = "submit" style="margin-left:300px; width:150px;" id="savebutton" name ="submit" class="button" value = "Create Project" onclick="userSubmitted = true;"/>
</fieldset>
</form>
What I want is to submit empty checkboxes also. and if user doesnt tick it set process column to 0 in database, and if ticks to 1. The problem is form sending both variables 1 and 0 if i tick the box. I tried to disable the one boxes which are ticked in javascript:
$(document).ready(function () {
if(document.getElementById("checked").checked) {
document.getElementById('unchecked').disabled = true;
}
});
But I still got both values. Is there a way to disable hidden inputs if checkboxes are checked?