<div class='container'><label for='vehicle'>Vehicle:</label><br/>
<span id='contactus_vehicle_errorloc' class='error'></span>
<input type="checkbox" name="vehicle" id="bike" value=<?php echo $formproc->SafeDisplay('bike') ?> /> I have a bike<br />
<input type="checkbox" name="vehicle" id="car" value=<?php echo $formproc->SafeDisplay('car') ?> /> I have a car <br />
<input type="checkbox" name="vehicle" id="motorbike" value=<?php echo $formproc->SafeDisplay('motorbike') ?> /> I have a motorbike <br/>
<input type="checkbox" name="vehicle" id="plane" value=<?php echo $formproc->SafeDisplay('plane') ?> /> I have a plane <br/>
<input type="checkbox" name="vehicle" id="papaki" value=<?php echo $formproc->SafeDisplay('papaki') ?> /> I have a papaki <br/>
</div>
user1360607
问问题
1048 次
4 回答
1
这很简单 - 将所有值相加,如果它至少是两个,那么你就可以了。
于 2012-04-27T08:19:05.897 回答
1
嗨,要计算选中复选框的数量。
- 替换
name="vehicle"
为name="vehicle[]"
. 通过车辆后值的这种变化,将出现一组检查值。
然后在php文件中
if(isset($_POST['vehicle'])){
/*check atleast 2 checked*/
if(sizeof($_POST['vehicle']) > 1){
//code comes here
}
}
谢谢
于 2012-04-27T08:43:25.783 回答
0
PHP 不知道 ID,它只知道名称。将名称更改为:
<input type="checkbox" name="vehicle[]" ///>
然后你可以像这样签入PHP:
<?php
if (count($_POST['vehicle]') >= 2) {
//do something
}
?>
于 2012-04-27T08:20:13.287 回答
0
像这样更改名称 name="vehicle[]" 然后在您的页面中
if (count($vehicle) < 2){
echo "please select at least two fields";
}
于 2012-04-27T08:20:25.173 回答