由于checkbox特殊性所以我们要获取它的值,在很我语言中都不一样的,在php教程 以我们是以数组形式来处理,并且利用遍历他的值,下面有大量实例。
checkbox demo demonstrates checkboxes fries soda shake ketchup 实例 $food = $_get[food]; $self = htmlentities($_server['php_self']); if (!empty($food)) { echo "the foods selected are:"; foreach($food as $foodstuf) { echo "".htmlentities($foodstuf).""; } } else { echo (" echo ('method="get"> italian mexican chinese checked="checked" /> '); } ?> 多选checkbox $optiOns= array('option 1', 'option 2', 'option 3'); $valid = true; if (is_array($_get['input'])) { $valid = true; foreach($_get['input'] as $input) { if (!in_array($input, $options)) { $valid = false; } } if ($valid) { //process input } } ?> 实例checkbox多值获取 $food = $_get["food"];//www.3ppt.com if (!empty($food)){ echo "the foods selected are: "; foreach($food as $foodstuff){ echo ''.htmlentities($foodstuff); } echo "."; } else { echo (' italian mexican chinese '); } ?>
实例
$food = $_get[food]; $self = htmlentities($_server['php_self']); if (!empty($food)) { echo "the foods selected are:"; foreach($food as $foodstuf) { echo "".htmlentities($foodstuf).""; } } else { echo (" echo ('method="get"> italian mexican chinese checked="checked" /> '); } ?>
多选checkbox
$optiOns= array('option 1', 'option 2', 'option 3'); $valid = true; if (is_array($_get['input'])) { $valid = true; foreach($_get['input'] as $input) { if (!in_array($input, $options)) { $valid = false; } } if ($valid) { //process input } } ?>
$optiOns= array('option 1', 'option 2', 'option 3');
$valid = true; if (is_array($_get['input'])) { $valid = true; foreach($_get['input'] as $input) { if (!in_array($input, $options)) { $valid = false; } } if ($valid) { //process input } } ?>
实例checkbox多值获取
$food = $_get["food"];//www.3ppt.com if (!empty($food)){ echo "the foods selected are: "; foreach($food as $foodstuff){ echo ''.htmlentities($foodstuff); } echo "."; } else { echo (' italian mexican chinese '); } ?>
$food = $_get["food"];//www.3ppt.com if (!empty($food)){ echo "the foods selected are: "; foreach($food as $foodstuff){ echo ''.htmlentities($foodstuff); } echo "."; } else { echo ('