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>
  • 相关阅读:
    JS年月日三级联动下拉列表
    日志分析软件
    配置Smarty
    JS无刷新省市两级联动下拉列表
    graylog2+syslogng+mongodb构建集中管理日志服务器
    syslog及syslogng详解
    php+pdo实现分页类代码
    编程实践62
    编程实践65
    编程实践64
  • 原文地址:https://www.cnblogs.com/xuerong/p/5062665.html
Copyright © 2011-2022 走看看