日期:2014-05-16 浏览次数:20736 次
<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>