Bootstrap模态框使用详解

一.模态框的正常点击出现,如添加功能

<td> <button type="button data-toggle="modal" data-target="#systemAdd">添加</button></td> <!-- 添加的模态框 --> </aside> <div role="dialog"> <div> <div> <div> <button type="button" data-dismiss="modal" aria-hidden="true">&times;</button> <h4>添加</h4> </div> <div> <form role="form-horizontal" action="${ctx}/system/addSystemUser.xht" method="post"> <div> <label for="name">用户ID</label> <input type="text" placeholder="请输入用户ID"> </div> <div> <label for="name">密码</label> <input type="text" placeholder="请输入密码"> </div> <div> <label for="name">系统ID</label> <input type="text" placeholder="请输入系统ID"> </div> <div> <label for="name">是否是管理员</label> <select> <option value="0">否</option> <option value="1">是</option> </select> </div> <div> <label for="name">删除标志</label> <select> <option value="0">正常</option> <option value="1">删除</option> </select> </div> <div> <label for="name">创建日期</label> <div> <input type='text' placeholder="请选择创建日期" data-date-format="YYYY-MM-DD HH:mm:ss" /> <span> <span></span> </span> </div> </div> </form> </div> <div> <button type="button" data-dismiss="modal">添加</button> <button type="button" data-dismiss="modal">关闭</button> </div> </div> </div> </div>

二.还有一种就是编辑,此时在弹出模态框时,里面要写入数据,所以要先取得数据再弹出模态框。这时要加入js代码控制

1.jsp页面

<td> <button type="button ">修改</button></td> <div role="dialog"> <div> <div> <div> <button type="button" data-dismiss="modal" aria-hidden="true">&times;</button> <h4>修改</h4> </div> <div> <form role="form-horizontal" action="${ctx}/system/updateUser.xht" method="post"> <div hidden="hidden"> <label for="name">NO</label> <input type="text" readonly> </div> <div hidden="hidden"> <label for="name">用户ID</label> <input type="text" readonly placeholder="请输入用户ID"> </div> <div> <label for="name">用户名</label> <input type="text" placeholder="请输入用户名"> </div> <div hidden="hidden"> <label for="name">密码</label> <input type="text" placeholder="请输入密码"> </div> <div> <label for="name">系统ID</label> <input type="text" placeholder="请输入系统ID"> </div> <div hidden="hidden"> <label for="name">是否是管理员</label> <select> <option value="0">否</option> <option value="1">是</option> </select> </div> <div> <label for="name">删除标志</label> <select> <option value="0">正常</option> <option value="1">删除</option> </select> </div> <div hidden="hidden"> <label for="name">创建日期</label> <div> <input type='text' data-date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择创建日期" /> <span> <span></span> </span> </div> </div> </form> </div> <div> <button type="button" data-dismiss="modal">修改</button> <button type="button" data-dismiss="modal">关闭</button> </div> </div> </div> </div>

2.js代码

/** * 修改用户(将用户信息写入模态框) */ function updateSystemUser() { var tempInput = new Input(); tempInput.userId = $('input[name="userId"]:checked').val(); if (tempInput.userId == null) { alert("请选择一条数据来修改"); } else { var params = JSON2.stringify(tempInput); var url = "/emailplatform/system/selectOneUser.xht"; ajaxJson(url, true, params, function(reObject) { // 开启模态框 var dialog = $('#systemUpp').modal({ backdrop : 'static', keyboard : false }); dialog.modal('show'); if (reObject) { $("#no1").val(reObject.data.no); $("#userId1").val(reObject.data.userId); $("#userName1").val(reObject.data.userName); $("#userPwd1").val(reObject.data.userPwd); $("#systemCode1").val(reObject.data.systemCode); $("#superFlg1").val(reObject.data.superFlg); $("#delFlg1").val(reObject.data.delFlg); $("#createTime1").val(reObject.data.createTime); } }); } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjfpxs.html