当我添加行时,我得到的ID如acctcode1 ... acctcode2 .. acctcode3等,但是当我想像子行时单击添加按钮,我需要子行ID如 cashpayment [1] .acctcode ,然后点击添加按钮,将其增加1 现金付款p [2] .acctcode
如何将父th值设置为子行或动态添加具有父名值的行需要增加百里香的索引。
<a id="add_row" class="btn btn-primary float-right adRow">Add New</a>
<div class="col-md-12 table-responsive">
<table class="table table-bordered table-hover table-sortable" id="tab_logic">
<thead style="background-color: #680779;
color: #fff;">
<tr>
<th class="text-center">
Account Code
</th>
<th class="text-center">
A/c Name*
</th>
<th class="text-center">
Narration*
</th>
<th class="text-center">
Debit*
</th>
<th class="text-center">
Credit
</th>
<th class="text-center" style="border-top: 1px solid #ffffff; border-right: 1px solid #ffffff;">
Action
</th>
</tr>
</thead>
<tbody>
<!-- th:each="cashpayment, stat : ${cashpayment.cashpay}" -->
<!-- <tr th:each="lstcashpayment:${cashPaymentList}"> -->
<tr id="fst_row">
<td>
<input type="number" id="payacc_code" placeholder='Enter A/c code' class="form-control" th:field="*{acctcode}" />
</td>
<td>
<select class=" form-control" id="payacc">
<option value="">Select TDS A/c name</option>
<!-- <option value="1">JOE</option>
<option value="2">JOE 2</option>
<option value="3">JOE 3</option> -->
</select>
</td>
<td>
<!-- th:field="*{cashpayments[__${row.index}__].code}" -->
<input type="text" class="form-control" id="pay_narrat" placeholder="Enter your here" data-toggle="modal" data-target="#narratModal" th:field="*{narration}" />
</td>
<td>
<!-- th:field="*{cashpayments[__${row.index}__].debit}" -->
<input type="number" id="paydeb" value="100" placeholder='Debit Amount' data-action="sumDebit" class="form-control" th:field="*{debitamt}" readonly />
</td>
<td>
<input type="number" id="paycredit" placeholder='Credit Amount' class="form-control" th:field="*{creditamt}" readonly />
</td>
<td>
<button class='btn btn-danger glyphicon glyphicon-remove row-remove removeBtn' style="cursor: not-allowed" disabled><span aria-hidden="true">×</span></button>
</td>
</tr>
<!-- <th:each="cashpayment$:{cashpayments}"> -->
<!-- class="hidden" -->
<tr id='addr0'>
<th:block th:each=cashpay,status:${cashpayment.cashpayments}>
<td data-name="cashacc_code">
<input type="text" id="cashacc_code" name="cashacc_code" placeholder='Enter A/c Code' class="form-control" th:attr="value = ${cashpay.acctcode}" th:field="*{cashpayments[__${status.index}__].acctcode}" />
</td>
<td data-name="sel">
<select class="form-control" name="cashacc_sel" id="cashacc_sel" th:field="*{cashpayments[__${status.index}__].acctname}">
<option value="">Select A/c name</option>
<!-- <option value="1">Plumz</option>
<option value="2">Plumz 2</option>
<option value="3">Plumz 3</option> -->
</select>
</td>
<td data-name="narrate">
<input type="text" class="form-control" id="acc_narrat" placeholder="Enter your here" name="acc_narrat" data-toggle="modal" data-target="#accnarratModal" th:field="*{cashpayments[__${status.index}__].narration}" />
</td>
<td data-name="dbt">
<input type="number" id="cashdeb" name='cashdeb' placeholder='Debit Amount' data-action="sumDebit" class="form-control" th:attr="value = ${cashpay.debit}" th:field="*{cashpayments[__${status.index}__].debit}" />
</td>
<td data-name="crdit">
<input type="number" id="cashcredit" name='cashcredit' placeholder='Credit Amount' class="form-control" readonly th:field="*{cashpayments[__${status.index}__].credit}" />
</td>
<td data-name="del">
<button name="del0" class='btn btn-danger glyphicon glyphicon-remove row-remove removeBtn'><span aria-hidden="true">×</span></button>
</td>
</th:block>
</tr>