1.陣列接收
<form
……
<input type="checkbox" name="address[ ]" value="桃園" /> 桃園
<input type="checkbox" name="address[ ]" value="台中" />台中
<input type="checkbox" name="address[ ]" value="高雄" />高雄
<input type="checkbox" name="address[ ] " value="台南" />台南
…….
接收的話,也是 $_POST[‘address’]
只不過 $_POST[‘address’] 是一個陣列
所以可以用
foreach($_POST[‘address’] as $val){
echo $val;
}
就可以找出所有值。
or
假如選了「台中」、「高雄」
$address=implode(“,",$_POST[‘address’]);
$address的值就是「台中,高雄」
2.serialize() 很好用 可以多用
$.ajax({
url: “test1.php",
data: $(‘#applyForm’).serialize(),
type:"POST",
dataType:’json’,
success: function(msg){
alert(“return="+msg);
},
error:function(xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});