原文:http://blog.csdn.net/baalhuo/article/details/51178154

模态框具体代码如下:

<!-- 模态框(Modal) -->
<div class="modal fade" id="update" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">修改信息</h4>
</div>
<div class="modal-body">
学号:<input type="text" name="stuno" id="stuno" />
密码:<input type="text" name="pass" id="pass"/>
姓名:<input type="text" name="stuname" id="stuname"/>
性别:<input type="radio" name="sex" class="sex" id="man" value="男"/>男
<input type="radio" name="sex" class="sex" id="women" value="女"/>女
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" onclick="update()">提交更改</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<!-- 模态框(Modal)end -->

单击编辑图标时触发模态框,并将此行数据传入模态框。

传入后如下:

具体传值方法如下

//触发模态框的同时调用此方法
function editInfo(obj) {
var id = $(obj).attr("id");
//获取表格中的一行数据
var stuno = document.getElementById("table").rows[id].cells[].innerText;
var pass = document.getElementById("table").rows[id].cells[].innerText;
var name = document.getElementById("table").rows[id].cells[].innerText;
var sex = document.getElementById("table").rows[id].cells[].innerText;
//向模态框中传值
$('#stuno').val(stuno);
$('#pass').val(pass);
$('#stuname').val(name);
if (sex == '女') {
document.getElementById('women').checked = true;
} else {
document.getElementById('man').checked = true;
}
$('#update').modal('show');
}
//提交更改
function update() {
//获取模态框数据
var stuno = $('#stuno').val();
var pass = $('#pass').val();
var name = $('#stuname').val();
var sex = $('input:radio[name="sex"]:checked').val();
$.ajax({
type: "post",
url: "update.do",
data: "stuno=" + stuno + "&pass=" + pass + "&name=" + name + "&sex=" + sex,
dataType: 'html',
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: function(result) {
//location.reload();
}
});
}
 

Bootstrap 模态框(Modal)插件数据传值的更多相关文章

  1. Bootstrap 模态框(Modal)插件

    页面效果: html+js: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  2. Bootstrap历练实例:模态框(Modal)插件

    模态框(Modal)是覆盖在父窗体上的子窗体.通常,其目的是显示来自一个单独源的内容,可以在不离开父窗体的情况下进行一些交互,子窗体提供一些交互或信息. <!DOCTYPE html>&l ...

  3. bootstrap模态框modal使用remote第二次加载显示相同内容解决办法

    bootstrap模态框modal使用remote动态加载内容,第二次加载显示相同内容解决办法 bootstrap的modal中,使用remote可以动态加载页面到modal-body中,并弹窗显示 ...

  4. bootstrap模态框modal使用remote动态加载内容,第二次加载显示相同内容解决办法

    bootstrap的modal中,使用remote可以动态加载页面到modal-body中,并弹窗显示 如果提供的是 URL,将利用 jQuery 的 load 方法从此 URL 地址加载要展示的内容 ...

  5. 禁用 Bootstrap 模态框(Modal) 点击空白时自动关闭

    在做项目的时候,来了这么一个需求,要求打开模态框后,点击空白的地方不让他自动关闭,只能点击关闭按钮才能关闭. 有了需求,就开始查找资料寻求解决的方法. 我找到的解决方法如下: $('#registCo ...

  6. Bootstrap模态框modal的高度和宽度设置

    (1)高度 将style=“height:900px”放在<div class = "modal-dialog">或者更外层上,整个模态框的高度不会发生变化 如下图所示 ...

  7. 黄聪:bootstrap的模态框modal插件在苹果iOS Safari下光标偏离问题解决方案

    一行CSS代码搞定: body.modal-open { position: fixed; width: 100%; }

  8. Bootstrap模态框(modal)垂直居中

    http://v3.bootcss.com/ 自己也试了改了几种方式也不容乐观,发现在窗口弹出之前是获取不到$(this).height()的值,本想着是用($(window).height()-$( ...

  9. Bootstrap模态框(MVC)

    BZ这篇博客主要是为大家介绍一下MVC如何弹出模态框.本文如果有什么不对的地方,希望大神们多多指教,也希望和我一样的小菜多多学习.BZ在这里谢过各位. 首先要在页面加上一个点击事件: @Html.Ac ...

  10. Bootstrap3模态框Modal垂直居中样式

    1,Bootstrap 模态框插件Bootbox垂直居中样式: <!DOCTYPE html> <html lang="en"> <head> ...

随机推荐

  1. 剑指offer55 字符流中第一个不重复的字符(最典型错误)

    典型并且基础的错误: class Solution { public: //Insert one char from stringstream void Insert(char ch) { ) res ...

  2. Paper: TranE

    论文标题:Translating Embeddings for Modeling Multi-relational Data 标题翻译:多元关系数据翻译嵌入建模 摘要: 考虑多元关系数据的实体和关系在 ...

  3. 十分钟看懂,未来Web前端开发最新趋势

    首先,展望未来趋势我们就要弄懂过去的一年,也就是18年,web前端开发的重要新闻.重要事件和JavaScript的各种流行框架.模式发展趋势. 我们来快速回顾一下. NPM热门前端框架下载 先来看最热 ...

  4. java基础—基础语法2

    一.语句

  5. 使用vs2013打开VS2015的工程文件的解决方案(适用于大多数vs低版本打开高版本)

    前言:重装系统前我使用的是vs2015(有点装*),由于使用2015实在在班上太另类了, 导致我想在其他同学的vs下看一看我写的代码都无法达成! 而且最关键的是交作业的时候,老师的2013也没有办法打 ...

  6. strlen、strcpy、strcat的实现

    概念: 1.strlen:strlen所作的仅仅是一个计数器的工作,它从内存的某个位置(可以是字符串开头,中间某个位置,甚至是某个不确定的内存区域)开始扫描,直到碰到第一个字符串结束符'\0'为止,然 ...

  7. 如何用纯 CSS 创作一个小球反弹的动画

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/OwWROO 可交互视频 ...

  8. 树莓派开发板入门学习笔记1:[转]资料收集及树莓派系统在Ubuntu安装

    参考教程(微雪课堂):http://www.waveshare.net/study/portal.php 树莓派实验室: http://shumeipai.nxez.com/2014/12/21/us ...

  9. BZOJ 4057: [Cerc2012]Kingdoms

    状压DP #include<cstdio> #include<cstring> using namespace std; int F[1200005],A[25][25],st ...

  10. 全网最详细python中socket套接字send与sendall的区别

    将数据发送到套接字. 套接字必须连接到远程套接字.  返回发送的字节数. 应用程序负责检查是否已发送所有数据; 如果仅传输了一些数据, 则应用程序需要尝试传递剩余数据.(需要用户自己完成) 将数据发送 ...