首页 > 其他 > 详细

grails之二级联动后的文本框内容的切换

时间:2015-10-09 12:13:01      阅读:234      评论:0      收藏:0      [点我收藏+]
技术分享
<td colspan="2">
        <staff:getDeptHtml  name="dept" value="" class="y-select dept" />   
        <span class="userTd"><staff:getUsersHtml name="user"  value="" class="y-select user"/> </span>
              <input type="text" id="usepersonphone"  name="usepersonphone" 
                   onkeyup="this.value = this.value.replace(/[^\d.]/g, ‘‘)"  onafterpaste="this.value=this.value.replace(/\D/g,‘‘)"
                        class="y-textbox" style="width:150px;"  >

  </td>

 <g:formRemote name="myForm" onSuccess="deptChangeSucc(data)" class="deptChange" url="[controller: ‘memberCarRepair‘, action: ‘changeDept‘]">
        <input type="hidden" name="deptid" id="deptid" type="text" />
 </g:formRemote>  
$(document).ready(function () {
           $(".dept").change(function(){
               var deptid = $(this).val()
              
               $(".deptChange #deptid").val(deptid);
               $(".deptChange").submit();
           });
    });

 function deptChangeSucc(data){
        $(".userTd").html(data)
        checkApplyPhone()
    }

 function checkApplyPhone(){
            $("select[name=‘user‘]").change(function(){
               var val = $(this).val()
               if(val!=‘‘){
                   $.ajax({
                      type: "post",//使用get方法访问后台
                      url: "<%=request.getContextPath()%>/memberCooperate/ajaxSelUser",//要访问的后台地址
                      data: "id="+val,//要发送的数据
                      success: function(msg){//msg为返回的数据,在这里做数据绑定
                        $("#usepersonphone").val(msg.phone)
                        $("#useperson").val(msg.realname)
                      }
                  });
               }else{
                   $("#usepersonphone").val("");
               }
           });          
   }

  

grails之二级联动后的文本框内容的切换

原文:http://www.cnblogs.com/yu0312chao/p/4863361.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!