急!谁能给个获得己选定CheckBox的VALUE值的函数<html> 
<head> 
<title>checkbox</title> <script type="text/javascript"> 
function getselectedcheckbox(valuestr){ 
//获得己选定CheckBox的VALUE值的函数      }
</script> 
</head> 
<body > 
<h2>Example </h2> 
 
<input type="checkbox" name="check" value="100" checked="true">复选1
<input type="checkbox" name="check" value="101" >复选2
<input type="checkbox" name="check" value="102" >复选3
<input type="checkbox" name="check" value="103"  checked="true">复选4
<input type="checkbox" name="check" value="104" >复选5
</body> 
</html>

解决方案 »

  1.   


    <html> 
    <head> 
    <title>checkbox</title> <script type="text/javascript"> 
    function getselectedcheckbox(){ 
    var checkArr = document.getElementsByName("check");
    var s = "";
    for(var i=0;i<checkArr.length;i++) {
    if(checkArr[i].checked) {
    s += checkArr[i].value + ",";
    }
    }
    alert("您选定的内容是:" + s);}
    </script> 
    </head> 
    <body > 
    <h2>Example </h2> 
     
    <input type="checkbox" name="check" value="100" checked="true">复选1
    <input type="checkbox" name="check" value="101" >复选2
    <input type="checkbox" name="check" value="102" >复选3
    <input type="checkbox" name="check" value="103"  checked="true">复选4
    <input type="checkbox" name="check" value="104" >复选5
    <input type="button" id="b1" value="获取值" onclick="getselectedcheckbox()"></body> 
    </html>
      

  2.   

      function chek(){
      var par;
      var che=document.getElementsByName("ck");
      for(var i=0; i<che.length;i++){
        if(che[i].checked){
          alert(che[i].value);
        }
       }
      }