我使用Mysql查询来获取所需的结果,并将其保存在和数组$newfamily中。现在,在这个数组的帮助下,我用给定的代码实现复选框-
<form method="get" action="specific_family.php">
<?php
foreach($newfamily as $name)
{
?>
<input type='checkbox'<?php echo $name;?>"><?php echo $name;?></input>
<?php
}
?>
</select> <input type = "submit" name="submit" >
</form>现在,在specific_family.php中,如何检索数组中选中的复选框值?此外,当我使用浏览器的后退按钮时,我可以看到以前选择的值是勾选的。我怎么才能把这个移除?
请指点。
发布于 2014-06-04 06:39:11
因此,如果将name属性添加到输入中:
<form method="get" action="specific_family.php">
<?php
foreach($newfamily as $name)
{
?>
<label for="<?php echo $name?>"><?php echo $name?></label>
<input type='checkbox' name="<?php echo $name;?>" id="<?php echo $name;?>"></input>
<?php
}
?>
</select> <input type = "submit" name="submit" >
</form>然后,您的复选框将以名称显示在您的$_GET数组中。
希望有帮助:)
发布于 2014-06-04 06:40:28
复选框应包括:
复选框需要:
它不应包括:
所以:
<label>
<input type="checkbox"
name="new_families[]"
value="<?php echo htmlspecialchars($name); ?>">
<?php echo htmlspecialchars($name); ?>
</label>然后,当表单提交时,所有复选框的值将出现在数组$_GET['new_families']中。
https://stackoverflow.com/questions/24030578
复制相似问题