php中多选提交如何获取,php中checkbox值获取,显示,多选值获取
php教程中checkbox值獲取,顯示,多選值獲取
最簡單checkbox獲取值代碼
checkboxdemo
checkbox
demo
demonstrates checkboxes
="handleformcheckbox.php">
="11.00">fries
="chksoda"? value ="12.85">soda
="checkbox" name ="chkshake" value ="1.30">shake
=".05">ketchup
="submit">
實例
using default checkboxvalues
$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
type="checkbox" name="food[]" value="mexican" />
chinese
value="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多值獲取
using default checkboxvalues
$food =
$_get["food"];
if (!empty($food)){
echo "the foods selected are:
";
foreach($food as $foodstuff){
echo '
/>'.htmlentities($foodstuff);
}
echo
".";
}
else {
echo ('
italian
value="italian" />
mexican
type="checkbox" name="food[]" value="mexican" />
chinese
value="chinese" checked="checked" />
');}
?>
總結
以上是生活随笔為你收集整理的php中多选提交如何获取,php中checkbox值获取,显示,多选值获取的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《SpringCloud超级入门》Eur
- 下一篇: 基于Echarts+HTML5可视化数据