由于checkbox特殊性所以我们要获取它的值,在很我语言中都不一样的,在php教程 以我们是以数组形式来处理,并且利用遍历他的值,下面有大量实例。
checkbox demo
checkbox demo
demonstrates checkboxes
实例
using default checkbox values
$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">
');
}
?>
多选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多值获取
using default checkbox values
$food = $_get["food"];//www.3ppt.com
if (!empty($food)){
echo "the foods selected are: ";
foreach($food as $foodstuff){
echo '
'.htmlentities($foodstuff);
}
echo ".";
}
else {
echo ('
');
}
?>