将复选框命名加上[]
如:
<input type="checkbox" name="checkbox[]" value="checkbox" />
<input type="checkbox" name="checkbox[]" value="checkbox" />
然后就有
$_POST["checkbox"][0]
$_POST["checkbox"][1]
如:
<input type="checkbox" name="checkbox[]" value="checkbox" />
<input type="checkbox" name="checkbox[]" value="checkbox" />
然后就有
$_POST["checkbox"][0]
$_POST["checkbox"][1]
function check_submit() {
var len_ex = document.compare.elements.length;
var select_num = 0;
var actioncon = "";
for(var i=0;i < len_ex;i++ )
{
var who = document.compare.elements[i];
var type = who.type;
var name = who.name;
if(type == "checkbox" || type == "CHECKBOX")
{
if(who.checked == true)
{
value = who.value;
if((value == "1")||(value == "2"))
{
select_num++;
actioncon += "&brands" + select_num;
actioncon += "=" + name;
actioncon += "&value" + select_num;
actioncon += "=" + value;
}
}
}
}
if(select_num > 3)
{
alert("抱歉,最多只能选择5个汽车品牌。请重新选择。");
return false;
}
else if( select_num == 0)
{
alert("请您选择汽车品牌。");
return false;
}
else
{
actioncon = "./compare.php?num=" + select_num +actioncon;
document.compare.action = actioncon;
window.location=actioncon;
return false;
}
}
我如果要在接受页得到select_num和brand的值应该如何操作。