zoukankan      html  css  js  c++  java
  • 无刷新 checkbox列表的删除

    前台 JS :

     function ModelDelete() {
                var checkvalues = null;
                var checValue = $("#dom1").find(":checkbox");
                for (var i = 0; i < checValue.length; i++) {
                    if (checValue[i].checked == true) {
                        if (checkvalues == null) {
                            checkvalues = checValue[i].value + ",";
                        }
                        else {
                            checkvalues += checValue[i].value + ",";
                        }
                    }
                }
                if (checkvalues == null || checkvalues == "") {
                    alert("请选择删除的数据");
                }
                else {
                    checkvalues = checkvalues.substring(0, checkvalues.lastIndexOf(","));
                    $.ajax({
                        type: "POST",
                        url: 'ProComparisonsAdd.aspx/TemDetele',
                        contentType: "application/json",
                        dataType: "json",
                        data: "{TemID:'" + checkvalues + "'}",
                        cache: false,
                        success: function (response) {
                            if (response != "") {
                                $("#dom1").html(response.d);
                            }
                        },
                        error: function (data) {
                            alert("加载失败");
                        }
                    });
                }
            }

    前台 HTML :

    <input id="btn1" type="button" value="删除" onclick="ModelDelete()" style=" 70px;" />
    <div id="dom1">
        <uc1:TemPlan ID="TemPlan1" runat="server">
    </div>


    后台代码:

            [WebMethod]//删除临时信息
            public static string TemDetele(string TemID)
            {
                XieKe.BLL.tb_PlanDetail tplan = new XieKe.BLL.tb_PlanDetail();
                tplan.Delete_TemList(TemID);
                Page page = new Page();
                TemPlan tem = (TemPlan)page.LoadControl("~/Web.JYK/TemPlan.ascx");
                tem.PageSort = "ProComparisionsAdd";
                page.Controls.Add(tem);
                StringWriter writer = new StringWriter();
                //加载 当前页面 的临时数据
                HttpContext.Current.Server.Execute(page, writer, false);
                return writer.ToString();
            }
  • 相关阅读:
    微信小程序入门
    webpack
    模块化开发(1)
    HTML5表单
    移动端入门
    MySQL
    js面向对象与PHP面向对象总结
    PHP
    Git指令
    Redux
  • 原文地址:https://www.cnblogs.com/SunXiaoLin/p/3345324.html
Copyright © 2011-2022 走看看