zoukankan      html  css  js  c++  java
  • ajax局部更新

    js
    
    //点击启用
            $(".status").on("click",function(){
                var id = $(this).attr("statusId");
                var customName = $(this).attr("customName");
                var customStatus = $(this).attr("value");
                var statusId = $(this).attr("statusId");
                if(customStatus == 1){
                    strcustomStatus = "停用";
                }else{
                    strcustomStatus = "启用";
                }
                alert(customStatus);
                //alert(customName);
                //alert(id);
                ymPrompt.win({ 
                                260,
                                   height:150,
                                icoCls: '',
                                message:'<div style="padding-top:25px;" class="message" align="center">您确定要'+strcustomStatus+'【'+customName+'】这个客户吗?</div>',
                                titleBar:false,
                                winPos:'c',
                                   btn:[['OK','ok'],['Cancel','no']],
                                   handler:function getButton(btn){
                                       if(btn == "ok"){
                                           $.ajax({
                                               type:"Post",
                                               data:{"customStatus":customStatus,"id":id},
                                               dataType:"json",
                                               url:classpath+"/updatecustomStatus",
                                               success:function(data){
                                                   if(data.customStatus==1){
                                                       //点击
                                                       $("span[statusId='"+statusId+"']").val(1);
                                                       $("span[statusId='"+statusId+"']").html("<font color='red'>停用</font>");
                                                       $("#"+statusId+"").val(0);
                                                       $("#"+statusId+"").html("启用");
                                                   }else{
                                                       $("span[statusId='"+statusId+"']").val(0);
                                                       $("span[statusId='"+statusId+"']").html("启用");
                                                       $("#"+statusId+"").val(1);
                                                       $("#"+statusId+"").html("<font color='red'>停用</font>");
                                                   }
                                               }
                                           });
                                       }
                                   }
                });

    页面

        <s:form  id="form" method="post">
            <table align="center" width="960" height="30" border="1px solid" id="find"/>
                <tr align="center" cellpadding="0">
                    <th width="65px">序号</th>
                    <th width="220px">客户名称</th>
                    <th width="200px">法人代表</th>
                    <th width="180px">注册时间</th>
                    <th width="80px">类型</th>
                    <th width="80px">状态</th>
                    <th width="135px">操作</th>
                </tr>
                  <s:iterator value="customsPageSupport.result" var="c" status="status">
                <tr align="center">
                    <td>
                        <s:property value="#status.index+1"/>
                    </td>
                    <td><s:property value="customName"/></td>
                    <td><s:property value="bossName"/></td>
                    <td><s:date name="regDatetime" format="yyyy-MM-dd"/></td>
                    <td><s:property value="customTypeName"/></td>
                    <td>
                        <span id="${c.id}" style="color:green" firststatusId="${c.id }" value="${c.customStatus }"><s:if test="customStatus == 1">启用</s:if>
                        <font color="red"><s:else>停用</s:else></font></span>
                    </td>
                    <td>
                        <span style="cursor:pointer" class="find" findId="${c.id }" >查看</span>                    
                        <span style="cursor:pointer" class="update" updateId="${c.id }">修改</span>
                        <span id="secondspan" style="color:green;cursor:pointer" class="status" statusId="${c.id }" value="${c.customStatus }" customName="${c.customName }"><s:if test="customStatus == 0">启用</s:if>    
                        <font color="red"><s:else>停用</s:else></font></span>                    
                    </td>
                </tr>
            </s:iterator>
  • 相关阅读:
    [转载]安装SQL Server 2008 R2遇到“...Setup has stopped working.”
    WPF验证错误显示
    说一下我对Mvvm模式的理解
    [转载]C#深拷贝的方法
    Windows Phone 开发(一):入门指南 — 安装开发环境:Windows Phone SDK
    DateTime.ToString() Patterns
    Log4net 根据日志类别保存到不同的文件,并按照日期生成不同文件名称
    使用Visual Studio 2010进行UI自动化测试
    WPF触发器之数据触发器(A)
    Getting The imported project "C:\Program Files\MSBuild\Microsoft\Silverlight for Phone\v4.0\Microsoft.Silverlight..Overrides.targets" was not found
  • 原文地址:https://www.cnblogs.com/xuerong/p/5062665.html
Copyright © 2011-2022 走看看