风故故,也依依

Stand still in the wind.

导航

获取checkbox的值

<SCRIPT LANGUAGE="JavaScript">

       function selectInst(){

              var checkbox = document.getElementsByName("inst");

              for(i=0;i<checkbox.length;i++){

                     if(checkbox[i].checked){

                            var temp = checkbox[i].value;

                            alert(temp);

                     }

              }

       }

</SCRIPT>

<form>

       选择爱好:<br>

       <input type="checkbox" name="inst" value="足球">足球

       <input type="checkbox" name="inst" value="篮球">篮球

       <input type="checkbox" name="inst" value="音乐">音乐

       <input type="checkbox" name="inst" value="上网">上网

       <input type="checkbox" name="inst" value="跳舞">跳舞

       <input type="button" value="提交" onclick="selectInst()">

</form>

posted on 2009-07-20 22:30  jadmin  阅读(276)  评论(0编辑  收藏  举报