Is it possible to see whether an element has been changed in the DOM?
In my case, I have a table with content editable and an id to access each table rows. I want to know which content has been changed.
<table id="myTable">
…
<td id=“name:1" contenteditable=“true"></td>
<td id=“phone:1” contenteditable="true"></td>
<td id=“address:1” contenteditable=“true"></td>
<td id=“name:2" contenteditable=“true"></td>
<td id=“phone:2” contenteditable="true"></td>
<td id=“address:2” contenteditable=“true"></td>
…
</table>
<input type="hidden" id="inputMyTable" name="inputMyTable">
So far I am using the DOM method to get the value of each cell and send it to the server. Then on the server side, for each row in the I database check if the value has been changed from the db then upgrade the db.
Is there a better way of doing this?
P.S. When I submit the form I send the table values to the server-side code with this script
var data = [];
$("#myTable tr").each(function(rowIndex) {
$(this).find("td").each(function(cellIndex) {
data.push($(this).text());
});
});
$('#inputMyTable').val(data.join(";"));
Then server-side I use $_POST
to read the output.