日期:2014-05-16 浏览次数:20370 次
<form onsubmit='return check()'> <input type='checkbox' name='cb'/> <input type='checkbox' name='cb'/> <input type='checkbox' name='cb'/> <input type='checkbox' name='cb'/> <input type='checkbox' name='cb'/> <input type='checkbox' name='cb'/> <input type='checkbox' name='cb'/> <input type='submit'/> </form> <script type='text/javascript'> function check(o) { var msg = ""; var checkboxes = document.getElementsByName('cb'); for(var i = 0 ; i < checkboxes.length ; i ++) { if(checkboxes[i].checked) msg +='第'+(i + 1) + "个被选中\n"; } alert(msg) } </script>