我有一个表,您可以使用按钮向其中添加行:
<div (window:onbeforeunload)="onUnload($event)">
<app-navbar></app-navbar>
<div class="main-body">
<div class="page-wrapper">
<router-outlet></router-outlet>
<app-login></app-login>
</div>
</div>
<app-footer></app-footer>
</div>
这是按钮逻辑:
@foreach($criteria as $row)
<tr>
<td width="10%" id="Iteration{{ $loop->iteration }}">{{ $loop->iteration }}</td>
<td width="80%">
<span><input id="Question{{ $loop->iteration }}" name="Question[]" placeholder="Question" class="form-control input-md warning" type="text" value="{{ $row->Question }}"></span>
<span><textarea id="Description{{ $loop->iteration }}" name="Description[]" placeholder="Description" class="form-control input-md warning">{{ $row->Description }}</textarea>
</td>
<td width="10%"><button class="btn btn-danger" type="button">DELETE</button></td>
</tr>
@endforeach
这很好用,它添加了新行,并且外观/功能与现有行相同。但是,新行在发布时不包括在请求中。这是怎么回事?它们是同一名称的一部分: $("#AddRow").click(function(){
var iteration = parseFloat($("#table tr:last td:first").html());
if (!iteration)
{
iteration = 0;
}
var newiteration = iteration + 1;
$('#table tr:last').after("<tr> <td width='10%' id='Iteration" + newiteration + "'>" + newiteration + "</td><td width='80%'><span><input id='Question" + newiteration + "' name='Question[]' placeholder='Question' class='form-control input-md warning' type='text' value=''></span><span><textarea id='Description" + newiteration + "' name='Description[]' placeholder='Description' class='form-control input-md warning'></textarea></td><td width='10%'><button class='btn btn-danger' type='button'>DELETE</button></td></tr>");
});
和Question[]
。有人有见识吗?
根据要求,以下是表格的完整代码:
Description[]
谢谢