添加 表格
<script type="text/javascript"> function Driver() { this._table = $('#lading-table'); this._tbody = this._table.find('tbody'); } Driver.prototype = { constructor: Driver, submit: function () { if (!this.check()) { alert('司机信息不能为空'); return; } var Pickings = $("input[name=Picking]").val(); var Aims = $("input[name=Aim]").val(); var data = this.getData(); //console.log(data); var Orderid = new String(); Orderid = '@ViewBag.OrderID'; $.ajax({ url: '/jb_PJ/PJ/DelegEd4', type: 'post', data: {}, dataType: 'json', success: function (data) { alert("操作成功"); location.reload(); }, error: function (err) { alert(data); } }); }, check: function () { var isTrue = true; var tr = this._tbody.find('tr'); tr.each(function () { var text = $(this).find('input[class="input"]'); text.each(function () { if ($(this).val() === '') { isTrue = false; return false; } }); }); return isTrue; }, getData: function () { var tr = this._tbody.find('tr'); var driver_list = []; tr.each(function () { var data_list = []; var text = $(this).find('input[class="input"]'); text.each(function () { data_list.push($(this).val()); }); driver_list.push(data_list.join(',')); }); return driver_list.join(';'); }, delRow: function (_this) { $(_this).parent().parent().remove(); var tr = $(_this).parents('tr'); var Log_ID = tr.find('input:eq(8)').val(); if (Log_ID != -1) { if (confirm('确实要删除吗?')) { //删除方法 $.ajax({ url: '/jb_PJ/PJ/Del_Log_ID', type: 'post', data: { id: Log_ID }, dataType: 'json', success: function (data) { if (data.code == 1) { layer.closeAll(); layer.confirm(data.msg, { btn: ['确认'] }, function () { location.reload(true); }); } else { layer.closeAll(); layer.alert(data['msg']); } } }); } } }, addRow: function () { var html = '\ <tr>\ <td><input onclick="Driver.prototype.delRow(this)" class="btn danger" type="button" value="删除"></td>\ <td><input class="input" type="text"></td>\ <td><input class="input" type="text"></td>\ <td><input class="input" type="text"></td>\ <td colspan="2"><input class="input" type="text" onkeyup="var reg = $(this).val().match(/\d+\.?\d{0,4}/);var txt = "";if (reg != null) { txt = reg[0];}$(this).val(txt);"></td>\ <td><input class="input" type="text" value="@ViewBag.YuanPianBil" onkeyup="var reg = $(this).val().match(/\d+\.?\d{0,4}/);var txt = "";if (reg != null) { txt = reg[0];}$(this).val(txt);"></td>\ <td><input class="input" type="text" onkeyup="var reg = $(this).val().match(/\d+\.?\d{0,4}/);var txt = "";if (reg != null) { txt = reg[0];}$(this).val(txt);" onchange="changeNum(this)"></td>\ <td><input class="input" type="text"></td>\ <input class="input" type="hidden" value="-1">\ </tr>\ '; this._tbody.append(html); }, addw: function () { var data = this.getData(); var Orderid = new String(); Orderid = '@ViewBag.OrderID'; $.ajax({ url: '/jb_PJ/PJ/YuanPianBill', type: 'post', data: { JsonData: data, OrderID: Orderid }, dataType: 'json', success: function (data) { console.log(data.data) }, error: function (err) { alert(data); } }); }, ToDecimal: function (obj) { obj.keyup(function () { var reg = $(this).val().match(/\d+\.?\d{0,2}/); var txt = ''; if (reg != null) { txt = reg[0]; } $(this).val(txt); }).change(function () { $(this).keypress(); var v = $(this).val(); if (/\.$/.test(v)) { $(this).val(v.substr(0, v.length - 1)); } }); } } var driver = new Driver(); </script>
<tr> <td colspan="4"> <table width="100%" cellspacing="0" cellspadding="0" border="0" id="lading-table"> <thead> <tr> <th rowspan="2"><input onclick="driver.addRow()" class="btn danger" type="button" value="增加"></th> <th rowspan="2">开票序号</th> <th rowspan="2">产品名称</th> <th rowspan="2">型号</th> <th colspan="2">数量(㎡)</th> <th rowspan="2">单价</th> <th rowspan="2">金额</th> <th rowspan="2">付款情况</th> </tr> <tr> <th><input disabled type="checkbox" name="vehicle" value="Car" checked="checked" />平米</th> <th><input disabled type="checkbox" name="vehicle" value="Car" />重箱</th> </tr> </thead> <tbody> <tr> <td> </td> <td><input class="input" type="text" value=""></td> <td><input class="input" type="text" value=""></td> <td ><input class="input" type="text" value=""></td> <td colspan="2"> <input class="input" type="text" value="" onkeyup="var reg = $(this).val().match(/\d+\.?\d{0,4}/);var txt = '';if (reg != null) { txt = reg[0];} $(this).val(txt);"> </td> <td><input class="input" type="text" value="@ViewBag.YuanPianBil" onkeyup="var reg = $(this).val().match(/\d+\.?\d{0,4}/);var txt = '';if (reg != null) { txt = reg[0];} $(this).val(txt);"></td> <td><input class="input" type="text" value="" onkeyup="var reg = $(this).val().match(/\d+\.?\d{0,4}/);var txt = '';if (reg != null) { txt = reg[0];} $(this).val(txt);" onchange="changeNum(this)"></td> <td><input class="input" type="text" value="" ></td> </tr> </tbody> </table> </td> </tr>
我曾拾到过一束光,日落时还给了夕阳。