zoukankan      html  css  js  c++  java
  • checkbox的各种操作

    1. js选中多个checkbox,取值向后台提交数据

    <html>
        <head>
            <script type="text/javascript" src="jquery-1.8.3.js"></script>
            <script>
                $(function() {        
                    $("#delete").click(function() {
                        //页面弹框
                        if(!confirm("确定要删除吗?")) {
                            window.event.returnValue = false;
                        }    
                        //调用函数
                        del();
                    });
                });
                    
                function del(){
                    //1.过滤出被选中的
                    var checkedList = $('input:checkbox').filter(":checked");
                    if (checkedList.length == 0) {
                        alert("未选中记录!");
                        return false;
                    }
                    var ids = "";
                    checkedList.each(function(){
                        ids += $(this).val()+",";
                    });
                    ids = ids.substring(0,ids.length-1);
                    //向后台发送数据
                    window.location.href = "/search/my_delete?data="+ids;
                }
            </script>
        </head>    
        <body>
            one:<input type="checkbox" value="one"/><br/>
            two:<input type="checkbox" value="two"/><br/>
            three:<input type="checkbox" value="three"/><br/>
            four:<input type="checkbox" value="four"/><br/>    
            <input type="button" id="delete" value="删除"/>
        </body>
    </html>
  • 相关阅读:
    我的Asp.Net Hello World程序

    快速排序
    Python是一门什么样的语言
    Python开发简介
    LVS(Linux Viretual Server) 负载均衡器 + 后端服务器
    易迷糊题
    python语言入门 第四天
    日常练习 1.0
    User_Login_Register_Shopping 1.0
  • 原文地址:https://www.cnblogs.com/shi-blog/p/4409557.html
Copyright © 2011-2022 走看看