MVC:html动态追加行及取值
先一个button id=addRow
点击事件进行添加
$("#addRow").bind("click", function () {
var rownum = $("#renyuanxinxi tr").size();//行数,便于查处追加出来的行数
var addHTML = "<tr><td><input type='text' value='" + rownum + "' style='width:30px;' readonly /></td><td><input type='text' style='width:40px;' /></td><td><input type='text' style='width:170px;' /></td><td><input type='text' style='width:110px;' /></td><td><select id='Select1'><option value='导游'>导游</option><option value='领队'>领队</option><option selected=selected' value='游客'>游客</option></select></td> <td><select id='Select1'><option value='男'>男</option><option value='女'>女</option></select> </td> <td><input type='text' style='width:60px;' /></td><td><input type='text' style='width:100px;' /></td><td><select id='Select2'> <option value='老年'>老年</option> <option value='儿童'>儿童</option><option value='其他'>其他</option></select></td> <td><select id='Select1'> <option value='待付款' selected='selected'>待付款</option><option value='已付款' >已付款</option></select> </td> <td><select id='Select1'><option value='待付款' selected='selected'>待付款</option><option value='现金'>现金</option><option value='支付宝'>支付宝</option><option value='微信' >微信</option></select></td><td><input type='text' style='width:100px;' /></td><td><input type='text' style='width:40px;' /></td></tr>";
$("#renyuan").append(addHTML); //根据id为renyuan的tbody标签进行append追加
});
取值并传值给controller 传过去的是名为list的一个集合
function addxingcheng() {
var AddData = [];
var XianluName=$("#aa").val();
$("#aaaaa>tr").each(function () {
var data = {
GxcId:,
GxcTianshu: $(this).find("td:eq(1)").children().val(),
GxcZhandian: $(this).find("td:eq(2)").children().val(),
GxcLeixing: $(this).find("td:eq(3)").children().val(),
GxcDidian: $(this).find("td:eq(4)").children().val(),
GxcShuoming: $(this).find("td:eq(5)").children().val(),
XianluName:XianluName
}
AddData.push(data);
})
var list = { list: AddData };
$.ajax({
type: "POST",
url: "/GenXianluFabu/GenXingchengAddDo",
data: JSON.stringify(list),//这个list是传给controller的list集合,controller需要用list
contentType: 'application/json, charset=utf-8',//这个必须写是对数据进行解析
success: function (data) {
}
});
MVC:html动态追加行及取值的更多相关文章
- 动态生成DropDownList 并取值
Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Def ...
- Angular配置路由以及动态路由取值传值跳转
Angular配置路由 1.找到 app-routing.module.ts 配置路由 引入组件 import { HomeComponent } from './home/home.componen ...
- LoadRunner进行参数化的九种方式取值和连接数据库取值
一.连接mysql数据库取值 1.首先安装odbc驱动 链接: https://pan.baidu.com/s/1WAYd4ygQqIrbB08S01hSkg 提取码: gdfs 2.操作步骤如下图: ...
- matlab-数组取值
一起来学matlab-数组取值 觉得有用的话,欢迎一起讨论相互学习~Follow Me MATLAB中的字符串符号 :冒号 s1=['I am sad';'you are ';'interest'] ...
- Webform动态创建删除行及后台取值
开发过程中经常碰到许多不确定事项,所以有时需要动态生成新的记录,如图所示,点击新增时新增一条参考记录,点击删除时则删除该记录:第一步,创建一个表格,用hidden记录当前最大行数,添加时则只需复制模板 ...
- js动态添加-表格逐行添加、删除、遍历取值
关于js对表格进行逐行添加,今天抽空整理了一下:新建一个html文件(没有编辑器的可以新建一个demo.txt文件,然后改后缀名为demo.html),把下面代码全部贴进去即可.功能包括:表格添加一行 ...
- LayUI 多选框动态加载、启用、禁用、赋值、取值等js实现
例如多选框如下: <div class="layui-form"> <select xm-select="city"> </sel ...
- ASP.NET MVC程序中动态修改form的Action值
在练习ASP.NET MVC时,为了实现一个小功能,POST数据至服务器执行时,需要动态修改form的action值. 下面Insus.NET列举一个例子来演示它.让它简单,明白易了解. 你可以在控制 ...
- 关于模板中的动态取值 ---反射与javascript脚本编译
在项目中经常遇到一个问题,打印word或者打印excel的时候,我们经常使用一对一的赋值或者批量替换的方式来对模板进行修改. 但是现在遇到两种场景: 1.取值是通过自定以方法进行取值的. 如:一个销售 ...
随机推荐
- iconfont的图文混排
最近在使用iconfont排版,但是发现完全没法混到textarea中. 希望借助 contentEditable 解决这个问题
- SDUT OJ 1221 亲和数 (找出某个数n所有的因子数,只需要暴力:2->sqrt(n) 即可 )
亲和数 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 如果a的因子和等于b,b的因子和等于a,且a≠b,则称a,b为亲和数对. ...
- LightOJ - 1422 Halloween Costumes —— 区间DP
题目链接:https://vjudge.net/problem/LightOJ-1422 1422 - Halloween Costumes PDF (English) Statistics F ...
- POJ1759 Garland —— 二分
题目链接:http://poj.org/problem?id=1759 Garland Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- AjaxControlToolkit没有通过WebResource.axd加载css导致ajaxToolkit:TabPanel无法显示正确的样式
https://stackoverflow.com/questions/3318092/what-is-webresource-axd WebResource.axd provides access ...
- oracle:数据库版本问题导致的bug
公司开发出来的系统,由于各现场oracle数据库版本有10.2.0.4.11.2.0.1.11.2.0.3.11.2.0.4: 进而会导致版本不一导致错误问题.下面列举2个: 1.wm_concat ...
- codeforces 696A A. Lorenzo Von Matterhorn(水题)
题目链接: A. Lorenzo Von Matterhorn time limit per test 1 second memory limit per test 256 megabytes inp ...
- CodeForces937B:Vile Grasshoppers(素数性质)
The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape. ...
- [Java] String类, StringBuffer类
1. String 类 1. 创建: String s1 = new String; s1 = "abc"; String s2 = new String("abc&qu ...
- 如何从kernel源码中查出版本号(转载)
转载:http://m.android.tgbus.com/tgmobile/arc/174624.shtml 目前查版本号的方法都是在编译以后从rootfs里看的,难道从源码就看不到,一定要编译以后 ...