Submit data from textbox only if it was changed or no longer blank?
Submit data from textbox only if it was changed or no longer blank?
I have a column with textbox generated by fnRender in my datatable. I am using it with submit form to generate sData string to later update database on the next page (per example below).
http://datatables.net/release-datatables/examples/api/form.html
I am having a problem that sData gets generated even when I do not change content inside those textboxes. How can I make sure that I generate sData only for those textboxes that been changed? (all textboxes are initially blank on each refresh of the page).
When I was experimenting with checkboxes, like in example, everything worked file.... sData would generate only when checkbox is checked. How can I fix this for textbox?
I am guessing it checked when input is checked, but not when it was changed.
[code]
var oTable;
$(document).ready(function () {
$('#SaveTable').submit( function() {
var sData = $('input', oTable.fnGetNodes()).serialize();
alert( "The following data would have been submitted to the server: \n\n"+sData );
return false;
} );
oTable = $('#LeaveApproval').dataTable({
"bLengthChange": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "LeaveApproval_Server_Side.asp<%=ProgramString %>",
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return ' ';
},
"aTargets": [ 8 ]
}
],
"aaSorting": [[ 1, "asc" ]]
} );
});
[/code]
http://datatables.net/release-datatables/examples/api/form.html
I am having a problem that sData gets generated even when I do not change content inside those textboxes. How can I make sure that I generate sData only for those textboxes that been changed? (all textboxes are initially blank on each refresh of the page).
When I was experimenting with checkboxes, like in example, everything worked file.... sData would generate only when checkbox is checked. How can I fix this for textbox?
I am guessing it checked when input is checked, but not when it was changed.
[code]
var oTable;
$(document).ready(function () {
$('#SaveTable').submit( function() {
var sData = $('input', oTable.fnGetNodes()).serialize();
alert( "The following data would have been submitted to the server: \n\n"+sData );
return false;
} );
oTable = $('#LeaveApproval').dataTable({
"bLengthChange": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "LeaveApproval_Server_Side.asp<%=ProgramString %>",
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return ' ';
},
"aTargets": [ 8 ]
}
],
"aaSorting": [[ 1, "asc" ]]
} );
});
[/code]
This discussion has been closed.