table中填写数据并批量增加
<table class = "table jtable table-bordered table-striped hide" id = "table_1" > <thead> <tr> <th style = "width: 50px;" >序号</th> <th style = "width: 150px;" >预算编号</th> <th style = "width: 100px;" >参考编号</th> <th style = "width: 220px;" >预算名称</th> <th style = "width: 100px;" class='teaDept' >部门</th> <th style = "width: 100px;" class='teaBrand'>品牌</th> <th style = "width: 100px;" class='teaBudItem'>预算科目</th> <th style = "width: 50px;" class='teaCompany'>公司</th> <th style = "width: 100px;" >预算币种</th> <th style="width: 50px;">操作</th> </tr> </thead> <tbody> <tr class = "tr_row" > <td> <span class="label label-sm label-success label-mini"> 1 </span> </td> <td> <input class = "form-control input-sm txt-required valid eaBudcode" id = "BudgetCode" name = "BudgetCode" type = "text" value = "" placeholder = "支持系统生成/用户输入,系统内唯一即可" data-bind="value:BudgetCode"/> </td> <td> <input class = "form-control input-sm eaClientCode" id = "tbClientCode" name = "tbClientCode" type = "text" value = ""/> </td> <td> <textarea rows = "2" class = "form-control input-sm txt-required valid eaBudName" id = "tbBudName" name = "tbBudName" ></textarea> </td> <td class='teaDept'> <select class = "fk-select form-control eaDept" id = "ddlDept" name="ddlDept" ></select> </td> <td class='teaBrand'> <select class = "fk-select form-control eaBrand" id = "ddlBrand" name="ddlBrand" > </select> </td> <td class='teaBudItem'> <select class = "fk-select form-control eaBudItem" id = "ddlBudItem" name="ddlBudItem"> </select> </td> <td class='teaCompany'> <select class = "fk-select form-control eaCompany" id = "ddlCompany" name="ddlCompany"> </select> </td> <td> <select class = "fk-select form-control eaCurrency" id = "ddlCurrency" name="ddlCurrency" > </select> </td> <td> <div class="input-group btn-group-xs margin-bottom-5"> <span class="input-group-btn margin-top-5" data-title="faplus"> <a href="javascript:void(0);" class="btn default btn-xs" name="CopyTr" title="复制"><i class="fa fa-plus"></i></a> </span> <span class="input-group-btn " data-title="faplus"> <a href="javascript:void(0);" class="btn default btn-xs" name="DelTr" title="删除"><i class="fa fa-minus"></i></a> </span> </div> </td> </tr> </table>
以下是table的js
/* 获取table表格的数据项.*/ function getTableData() { var data = []; $("#table_1 tbody tr").each(function(i, item) { data.push({ "BudgetCode" : $("input[name='BudgetCode']", item).val(), "ClientCode" : $("input[name='tbClientCode']", item).val(), "BudgetName" : $("textarea[name='tbBudName']", item).val(), "DeptID" : $("select[name='ddlDept']", item).val(), "BrandID" : $("select[name='ddlBrand']", item).val(), "BudgetItemID" : $("select[name='ddlBudItem']", item).val(), "CompanyID" : $("select[name='ddlCompany']", item).val(), "CurrencyID" : $("select[name='ddlCurrency']", item).val(), "BudCategoryID": $("#ddlBudCategory").val(), //预算类别id "ParentID": $("#tbParBudCode").val() //上级编号 }); }); //console.log("data1:" + data); return data; //返回数据 }