Befolgen Sie die folgende Tabelle, wie kann ich die Zeileneingabe bei Auswahl ändern?Füllen Sie den Eingang nach der Änderung auf einer Auswahl
Ich habe mehrere Zeilen als die eine.
<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>
Ich habe tatsächlich:
$('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);
});
Vielen Dank.
Das 'name' Attribut des' input' Tag „BIL_Rate [] ". Was ist mit den Klammern? – Chet
Ursache das Endergebnis sollte behandelt werden wie ein Array. Ich habe mehrere Zeilen so. – user8201518