php checkbox復(fù)選框值的獲取與checkbox默認(rèn)值輸出方法
更新時間:2010年05月15日 18:54:33 作者:
php獲取 checkbox復(fù)選框值的方法,checkbox在php讀取值時要用數(shù)組形式哦,我們讀取這些值用php post獲取是以一個array形式哦。
php獲取 checkbox復(fù)選框值的方法
<html xmlns="http://www.dhdzp.com/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php獲取 checkbox復(fù)選框值的方法</title>
</head>
<body>
<form name="form1" method="post" action="">
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選一">
復(fù)選一
</label>
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選二">
</label>
復(fù)選二
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選三">
</label>
復(fù)選三
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選四">
</label>
復(fù)選四
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
</body>
</html>
<?
if( $_POST )
{
$value = $_POST['checkbox'];
echo '你選擇了:'.implode(',',$value);
//由于checkbox屬性,我們必須把checkbox復(fù)選擇框的名字設(shè)置為一個如果checkbox[],這樣php才能讀取,以數(shù)據(jù)形式,否則不能正確的讀取checkbox復(fù)選框的值哦。//腳本之家 jb51.net 整理
}
?>
checkbox在php讀取值時要用數(shù)組形式哦,我們讀取這些值用php post獲取是以一個array形式哦,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php獲取多選框checkbox值</title>
</head>
<body>
<?php
$area_arr = array();
if($_GET['action']=="submit"){
$area_arr = $_POST['area'];
}
echo "您選定的地區(qū)為: ";
foreach ($area_arr as $k=>$v){
echo $v." ";
}
?>
<form id="form1" name="form1" method="post" action="?action=submit">
<p>河北
<label>
<input type="checkbox" id="area" name="area[]" value="河北">
</label>
</p>
<p>河南
<label>
<input type="checkbox" id="area[]" name="area[]" value="河南">
</label>
</p>
<p>山西
<label>
<input type="checkbox" id="area[]" name="area[]" value="山西">
</label>
</p>
<p>山東
<label>
<input type="checkbox" id="area[]" name="area[]" value="山東">
</label>
</p>
<p>江蘇
<label>
<input type="checkbox" id="area[]" name="area[]" value="江蘇">
</label>
</p>
<p>浙江
<label>
<input type="checkbox" id="area[]" name="area[]" value="浙江">
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="提交">
</label>
</p>
</form>
</body>
</html>
php checkbox默認(rèn)選擇問題(都是利用的這種原理)
<input name="jb51" type="checkbox" value="jiaju" <?php if($myrow[fujia_jiaju]) echo("checked");?>>
復(fù)制代碼 代碼如下:
<html xmlns="http://www.dhdzp.com/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php獲取 checkbox復(fù)選框值的方法</title>
</head>
<body>
<form name="form1" method="post" action="">
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選一">
復(fù)選一
</label>
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選二">
</label>
復(fù)選二
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選三">
</label>
復(fù)選三
<label>
<input type="checkbox" name="checkbox[]" value="復(fù)選四">
</label>
復(fù)選四
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
</body>
</html>
<?
if( $_POST )
{
$value = $_POST['checkbox'];
echo '你選擇了:'.implode(',',$value);
//由于checkbox屬性,我們必須把checkbox復(fù)選擇框的名字設(shè)置為一個如果checkbox[],這樣php才能讀取,以數(shù)據(jù)形式,否則不能正確的讀取checkbox復(fù)選框的值哦。//腳本之家 jb51.net 整理
}
?>
checkbox在php讀取值時要用數(shù)組形式哦,我們讀取這些值用php post獲取是以一個array形式哦,
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php獲取多選框checkbox值</title>
</head>
<body>
<?php
$area_arr = array();
if($_GET['action']=="submit"){
$area_arr = $_POST['area'];
}
echo "您選定的地區(qū)為: ";
foreach ($area_arr as $k=>$v){
echo $v." ";
}
?>
<form id="form1" name="form1" method="post" action="?action=submit">
<p>河北
<label>
<input type="checkbox" id="area" name="area[]" value="河北">
</label>
</p>
<p>河南
<label>
<input type="checkbox" id="area[]" name="area[]" value="河南">
</label>
</p>
<p>山西
<label>
<input type="checkbox" id="area[]" name="area[]" value="山西">
</label>
</p>
<p>山東
<label>
<input type="checkbox" id="area[]" name="area[]" value="山東">
</label>
</p>
<p>江蘇
<label>
<input type="checkbox" id="area[]" name="area[]" value="江蘇">
</label>
</p>
<p>浙江
<label>
<input type="checkbox" id="area[]" name="area[]" value="浙江">
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="提交">
</label>
</p>
</form>
</body>
</html>
php checkbox默認(rèn)選擇問題(都是利用的這種原理)
復(fù)制代碼 代碼如下:
<input name="jb51" type="checkbox" value="jiaju" <?php if($myrow[fujia_jiaju]) echo("checked");?>>
php入門學(xué)習(xí)知識點一 PHP與MYSql連接與查詢
php入門學(xué)習(xí)知識點一 PHP與MYSql連接與查詢,學(xué)習(xí)php最重要的就是與數(shù)據(jù)庫的交互。
2011-07-07
php面向?qū)ο笕ヂ?(四)構(gòu)造方法與析構(gòu)方法
大多數(shù)類都有一種稱為構(gòu)造函數(shù)的特殊方法。當(dāng)創(chuàng)建一個對象時,它將自動調(diào)用構(gòu)造函數(shù),也就是使用new 這個關(guān)鍵字來實例化對象的時候自動調(diào)用構(gòu)造方法。
2009-09-09
關(guān)于PHP中操作MySQL數(shù)據(jù)庫的一些要注意的問題
關(guān)于PHP中操作MySQL數(shù)據(jù)庫的一些要注意的問題...
2006-10-10 
