按照下表,我如何在选择更改时填充行输入?在选择更改后填充输入
我有几行作为一个。
<table class="table table-striped table-bordered">
<tbody>
<tr>
<th width="60%">Date</th>
<th width="40%">Rate</th>
</tr>
<tr>
<th>Today<br><select name="RAT_Rates" class="form-control"><option data-name="" data-description="" data-rate="" selected="">Custom</option><option data-name="Special" data-description="Special" data-rate="99.99"> Special - $ 99.99</option></select></th>
<td>
<div class="col-sm-12">
<input type="text" name="BIL_Rate[]" class="form-control" required="">
</div>
</td>
</tr>
<tr>
<th>Tomorrow<br><select name="RAT_Rates" class="form-control"><option data-name="" data-description="" data-rate="" selected="">Custom</option><option data-name="Special" data-description="Special" data-rate="99.99"> Special - $ 99.99</option></select></th>
<td>
<div class="col-sm-12">
<input type="text" name="BIL_Rate[]" class="form-control" required="">
</div>
</td>
</tr>
</tbody>
</table>
我亲眼:
$('select[name=RAT_Rates]').on('change', function() {
var selected = $(this).find('option:selected');
var name = selected.attr('data-name');
var description = selected.attr('data-description');
var rate = selected.attr('data-rate');
$(this).next('input[name=BIL_Rate]').val(rate);
});
非常感谢。
的''的标签input'的name'属性是“BIL_Rate []”。括号是什么? – Chet
导致最终结果应该像数组一样对待。我有这样的几排。 – user8201518