확인란을 모두 선택/모두 선택 안 함, 결과 제출 선택

2343 단어
<html>
 
<head>
    <meta charset="utf-8">
    <!--    jQuery -->
    <script src="../scripts/jquery-1.3.1.js" type="text/javascript"></script>
     
    <script>
        $(function(){
            $("#CheckedAll").click(function(){
                if(this.checked) // 
                {
                    $('input[type=checkbox][name=items]').attr("checked", true);
                }
                else
                {
                    $('input[type=checkbox][name=items]').attr("checked", false);
                }
            });
             
            $("input[type=checkbox][name=items]").click(function(){
                var flag=true;
                $("input[type=checkbox][name=items]").each(function(){
                    if(!this.checked) // 
                    {
                        flag=false;
                    }
                });
                 
                if(flag)
                {
                     $('#CheckedAll').attr('checked', true );
                }
                else
                {
                     $('#CheckedAll').attr('checked', false );
                }
            });
             
            $("#send").click(function(){
                var str="";
                $("input[type=checkbox][name=items]:checked").each(function(){
                    str += $(this).val() + "\r
";                     })                 alert(str);             })         })     </script> </head>   <body>       <form>          :         <input type="checkbox"  id="CheckedAll"/ > /         <br />                   <input type="checkbox" name="items" value=" " />         <input type="checkbox" name="items" value=" " />         <input type="checkbox" name="items" value=" " />         <input type="checkbox" name="items" value=" " />         <br />                   <input type="button" id="send" value=" " />     </form> </body> </html>

좋은 웹페이지 즐겨찾기