I'm trying to display the input data in a table format. The issue I'm having now is the display table will show the last data that was input.
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 : Input Table
Name Value 1 Value 2
Topic1 1 100
Topic2
Results Display Table
Name Value 1 Value 2
Topic1 1 100
Topic2 1 100
EX 2 : Input Table
Name Value 1 Value 2
Topic1 1 100
Topic2 2 200
Results Display Table
Name Value 1 Value 2
Topic1 2 200
Topic2 2 200
Desired Result:
Name Value 1 Value 2
Topic1 1 100
Topic2 2 200
JSFiddle https://jsfiddle.net/bhfhd4yr/18/