我有一个复选框循环。我把一个隐藏的字段放在里面,具有不同的值和不同的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>
我想要的是提交空复选框。如果用户没有勾选,则在数据库中将进程列设置为0,如果勾选为1.问题是如果我勾选框,则发送变量1和0的表单。我试图禁用在javascript中打勾的一个框:
$(document).ready(function () {
if(document.getElementById("checked").checked) {
document.getElementById('unchecked').disabled = true;
}
});
但我仍然有两个价值观。如果选中复选框,有没有办法禁用隐藏的输入?