您的位置:首页 > 编程语言 > ASP

处理ASP中checkbox 在 form enctype="multipart/form-data"中只能取一个的问题

2008-10-24 15:41 615 查看
借助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" onclick="ck(this)"/>

<input type="checkbox" name="category" id="category" value="2" onclick="ck(this)"/>

<input type="checkbox" name="category" id="category" value="3" onclick="ck(this)"/>

</form>

这种仅在数据量比较小的情况,因为hidden的长度是有限制的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐