How to Get Old and New Value Using Change Event
Hi Guys,
I already have a working change event + AJAX now I have to make a historical data by adding a new table in mySQL called
tb_historical. Now I want to get the previous value to be captured as well so I can do 2 AJAX POST for my current table and the historical table here's what I got so far:
Here's for a select tag
- $(".sup_class").change(function() {
- var sup_name_update = $("option:selected", this).text();
- var sup_nt_update = $("option:selected", this).val();
- var assoc_id = $(this).closest('tr').find('.assoc_id_class').val();
- var confirmExport = confirm("You're about to transfer this associate, are you sure?");
- if (confirmExport){
- $.ajax({
- type: "POST",
- url: "ajaxp_update_user_add.php",
- data: {sup_name: sup_name_update, assoc_id: assoc_id, sup_nt: sup_nt_update},
- success: function (){
- $("#confirmation").show().delay(1000);
- $("#confirmation").fadeOut();
- }
- });
- }
- });
And here's for a more common input tag
-
- $(".cuic_name").change(function() {
- var cuic_name = $(this).val();
- var assoc_id = $(this).closest('tr').find('.assoc_id_class').val();
- $.ajax({
- type: "POST",
- url: "ajaxp_cuic_name_update.php",
- data: {cuic_name: cuic_name, assoc_id: assoc_id},
- success: function (){
- $("#confirmation_m").show().delay(1000);
- $("#confirmation_m").fadeOut();
- }
- });
- });
I'm wondering if we can just add a new variable where it can capture the old data so that it's just one line.
I would really appreciate your help. :)