How to Get Old and New Value Using Change Event

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 
  1. $(".sup_class").change(function() {
  2. var sup_name_update = $("option:selected", this).text();
  3. var sup_nt_update = $("option:selected", this).val();
  4. var assoc_id = $(this).closest('tr').find('.assoc_id_class').val();
  5. var confirmExport = confirm("You're about to transfer this associate, are you sure?");
  6. if (confirmExport){
  7. $.ajax({
  8. type: "POST",
  9. url: "ajaxp_update_user_add.php",
  10. data: {sup_name: sup_name_update, assoc_id: assoc_id, sup_nt: sup_nt_update},
  11. success: function (){
  12. $("#confirmation").show().delay(1000);
  13. $("#confirmation").fadeOut();
  14. }
  15. });
  16. }
  17. });
And here's for a more common input tag

  1. $(".cuic_name").change(function() {
  2. var cuic_name = $(this).val();
  3. var assoc_id = $(this).closest('tr').find('.assoc_id_class').val();
  4. $.ajax({
  5. type: "POST",
  6. url: "ajaxp_cuic_name_update.php",
  7. data: {cuic_name: cuic_name, assoc_id: assoc_id},
  8. success: function (){
  9. $("#confirmation_m").show().delay(1000);
  10. $("#confirmation_m").fadeOut();
  11. }
  12. });
  13. });

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. :)