I have the following form:
<form >
<input value="333" id="modal_Order_1" class="update-grid">
<input value="xxx" id="modal_Link_1" class="update-grid">
<input value="yyy" id="modal_Title_1" class="update-grid">
</form>
and a table:
<tr id="row_1" >
<td><input id="input_Order_1"></td>
<td><input value="x" id="input_Link_1"></td>
<td><input value="y" id="input_Title_1"></td>
</tr>
I have the following code that one by one takes values from the form and updates the table row. Note that my code knows the row number as it is in the rowNum variable:
var rowNum = oSubmit.rownum;
var order = $form.find("#Content_Order").val();
var link = $form.find("#Content_Link").val();
var title = $form.find("#Content_Title").val();
$("#input_Order_" + rowNum).val(order);
$("#input_Link_" + rowNum).val(link);
$("#input_Title_" + rowNum).val(title);
Is there a way that I could replace the code above with a loop for each input values on the form that have a class of update-grid and then updates the table fields where the last part of the names match ?
Try this: