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

 

 

借助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的长度是有限制的

posted @ 2008-10-24 15:41  alex hu  阅读(1422)  评论(0编辑  收藏  举报