日期:2014-05-17  浏览次数:20780 次

一个简单的编程
<form   action= " "   method=post>
    <input   type= "checkbox "   name= "a1 "   value= "11 ">
    <input   type= "checkbox "   name= "a2 "   value= "11 ">
    <input   type= "checkbox "   name= "a3 "   value= "11 ">
    <input   type= "checkbox "   name= "a4 "   value= "11 ">
                                                .
                                                .
                                                .
    <input   type= "checkbox "   name= "a15 "   value= "11 ">
</form>
  ==============================
请编一个程序循环获取这些值。


------解决方案--------------------
使用同一个名字,获取的值会自动以逗号隔开。
------解决方案--------------------
<form action= " " method=post>
<input type= "checkbox " name= "a1 " value= "11 ">
<input type= "checkbox " name= "a2 " value= "11 ">
<input type= "checkbox " name= "a3 " value= "11 ">
<input type= "checkbox " name= "a4 " value= "11 ">
<input type= "checkbox " name= "a15 " value= "11 ">
</form>
<script>
f = document.forms[0];
for(c=0; c <f.length; c++) alert(f.elements[c].value);
</script>