Ich versuche, die Eingabedaten in einem Tabellenformat anzuzeigen. Das Problem, das ich jetzt habe, ist die Anzeigetabelle zeigt die letzten Daten, die eingegeben wurden.Anzeige von Daten aus Eingabefeldern in einem Tabellenformat
HTML:
<table>
<thead>
<tr>
<th>Name</th>
<th>Value 1</th>
<th>Value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Topic1</td>
<td><input type="text" class="Value_One"/></td>
<td><input type="text" class="Value_Two"/></td>
</tr>
<tr>
<td>Topic2</td>
<td><input type="text" class=" Value_One"></td>
<td><input type="text" class=" Value_Two"></td>
</tr>
</tbody>
</table>
<br/>
<table>
<thead>
<tr>
<th>Name</th>
<th>Value 1 </th>
<th>Value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name">Topic1 </td>
<td class="value_1"></td>
<td class="value_2"></td>
</tr>
<tr>
<td class="name">Topic2</td>
<td class="display_value_1"></td>
<td class="display_value_2"></td>
</tr>
</tbody>
</table>
jQuery:
$(document).ready(function() {
$('input.Value_One').on('keyup change', function() {
$('td.display_value_1').text($(this).val());
});
$('input.Value_Two').on('keyup change', function() {
$('td.display_value_2').text($(this).val());
});
});
EX 1: Eingabetabelle
Name Value 1 Value 2
Topic1 1 100
Topic2
Ergebnisse Anzeige Tabelle
Name Value 1 Value 2
Topic1 1 100
Topic2 1 100
EX 2:
EingabetabelleName Value 1 Value 2
Topic1 1 100
Topic2 2 200
Ergebnisse Anzeige Tabelle
Name Value 1 Value 2
Topic1 2 200
Topic2 2 200
Gewünschtes Ergebnis:
Name Value 1 Value 2
Topic1 1 100
Topic2 2 200
JSFiddle https://jsfiddle.net/bhfhd4yr/18/
aussieht wie ein paar Dinge mit Ihren Klassennamen sind. Sie haben zwei Zuhörer aber vier Felder .... – deweyredman
@deweyredman hat Recht. Sie müssen Ihre Listener aktualisieren ... [https://jsfiddle.net/bhfhd4yr/20/](https://jsfiddle.net/bhfhd4yr/20/) –