次の表に従って、選択変更時に行入力をどのように設定できますか?選択後に入力後に入力を入力する
私は1つとして複数の行を持っています。
<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);
});
おかげで多くのことを。
' name'の属性が「BIL_Rateです[] "。括弧は何ですか? – Chet
最終的な結果は配列のように扱う必要があります。私はこのようにいくつかの行を持っています。 – user8201518