借助JS
function recheck(form)
{
var temp=document.getElementById("categories");
temp.value=(temp.value.substring(0,1)==",")?temp.value.substring(1,temp.value.length):temp.value;
return true;
}
function ck(o)
{
var v=o.value;
var temp=document.getElementById("categories");
temp.value=(o.checked)?temp.value+","+v:temp.value.replace(","+v,"");
}
<FORM method="post" enctype="multipart/form-data" name="form1" onSubmit="return recheck(this)">
<input type="hidden" name="categories" id="categories" />
<input type="checkbox" name="category" id="category" value="1" οnclick="ck(this)"/>
<input type="checkbox" name="category" id="category" value="2" οnclick="ck(this)"/>
<input type="checkbox" name="category" id="category" value="3" οnclick="ck(this)"/>
</form>
这种仅在数据量比较小的情况,因为hidden的长度是有限制的