日期:2014-05-16 浏览次数:20352 次
<form action="" method="post" name="voteform" id="voteform" onsubmit="return Check();"> <table> <tr> <td width="75"></td> <td colspan="4" class="votetitle" height="18">A</td> <tr> <tr> <td width="75"></td> <td width="140"><input type="checkbox" name="conditions[]" value="1" />1</td> <td width="140"><input type="checkbox" name="conditions[]" value="2" />2</td> <td width="140"><input type="checkbox" name="conditions[]" value="3" />3</td> <td width="140"><input type="checkbox" name="conditions[]" value="4" />4</td> </tr> <tr> <td width="75"></td> <td colspan="4" class="votetitle" height="18">B</td> <tr> <tr> <td width="75"></td> <td width="140"><input type="checkbox" name="hstyle[]" value="1" />1</td> <td width="140"><input type="checkbox" name="hstyle[]" value="2" />2</td> <td width="140"><input type="checkbox" name="hstyle[]" value="3" />3</td> <td width="140"><input type="checkbox" name="hstyle[]" value="4" />4</td> </tr> <tr><td colspan="5" height="15"></td></tr> <tr> <td colspan="5" class="votetitle" height="18" align="center"><input type="submit" name="submit" value="提交"/></td> <tr> </table> </form>
<html> <head> <script> function Check(form){ var obj = form.elements["conditions[]"]; var arr = []; arr.push("conditions[]: "); for(var i = 0; i < obj.length; i++){ if(obj[i].checked){ arr.push(obj[i].value); } } var obj1 = form.elements["hstyle[]"]; arr.push(" hstyle[]: "); for(var i = 0; i < obj1.length; i++){ if(obj1[i].checked){ arr.push(obj1[i].value); } } alert(arr.join(",")); return false; } </script> </head> <body> <form action="" method="post" name="voteform" id="voteform" onsubmit="return Check(this);"> <table> <tr> <td width="75"></td> <td