首页 » 前端开发 » 正文

bootstrap给模态窗口传参

bootstapmotai

实现点击改密后打开一个模态窗口,传递id。

按钮:

<button class="btn btn-warning btn-xs submitedit" type="button" datavalue="{$vo.id}" data-toggle="modal" data-target="#myModal" rel="{$vo.id}"><i class="fa fa-paste"></i> 改密</button>

模态窗口:

<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
     <div class="modal-dialog">
           <div class="modal-content animated bounceInRight">
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span></button>
                 </div>
                 <div class="modal-body">
		<input name="cid" id="cid" type="hidden" value="">
                <div class="form-group"><label>新密码</label> <input name="pass" id="pass" type="password" class="form-control"></div>
                <div class="form-group"><label>重复新密码</label> <input name="repass" id="repass" type="password" class="form-control"></div>
                 </div>
             <div class="modal-footer">
      <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
      <button type="button" class="btn btn-primary baocun">保存</button>
             </div>
           </div>
       </div>
</div>

js部分:

		//打开改密窗口
		  $(".submitedit").click(function() {
		  	//清理
			$("#cid").val('');
			$("#pass").val('');
			$("#repass").val('');
			var id = $(this).attr('rel');
			$("#cid").val(id);
		  });	

		//改密
		  $(".baocun").click(function() {
			var cid = $("#cid").val();
			var pass = $("#pass").val();
			var repass = $("#repass").val();
			if (cid=="") {parent.layer.msg('未选择用户!');return false;}
			if (pass=="" || repass=="") {parent.layer.msg('密码不能留空!');return false;}
			if (pass!=repass) {parent.layer.msg('两次输入的密码不相同!');return false;}

			$.get('{:url("Hplus/index/editpass")}','cid='+cid+'&pass='+pass+'&repass='+repass,function (msg) { 
				parent.layer.msg(msg);
				$("#myModal").modal('hide');
			});	 
			
		  });	

博主的文章或程序如果给您带来了价值,感谢您打赏一二
微信扫码支付 支付宝扫码支付

发表评论