CheckBox value html
<form name="f1">a:<input type="checkbox" name="n1" value="a" title="1"><br/>b:<input type="checkbox" name="n1" value="b" title="1"><br/>c:<input type="checkbox" name="n1" value="c" title="1"><br/><input type="button" id="b" value="tijiao"></form><script type="text/javascript"> var b = document.getElementById("b"); b.onclick = function(){ var chV=""; var inputElements =document.getElementsByTagName("input"); for(var i=0; inputElements[i]; ++i){ if(inputElements[i].name==="n1" && inputElements[i].checked){ chV+=inputElements[i].value+","; } } alert(chV.substring(0,chV.length-1)); };</script>
<script> <br /> var b = document.getElementById("b"); <br /> b.onclick = function(){ <br /> var sign = 0; <br /> var inputs = document.getElementsByTagName('input');//获取所有的input标签对象。 <br /> for(var i=0;i<inputs.length;i++){ <br /> var obj = inputs[i]; <br /> if(obj.type=='checkbox'){ <br /> if(obj.checked==true){ <br /> sign=1; <br /> alert(obj.value); <br /> } <br /> } <br /> } <br /> if(sign==0)//没有被选择项 <br /> { <br /> alert("未选择"); <br /> } <br /> } <br /> <br /> </script>