我正在編輯一個應該在值更改時更新數據庫的代碼,但是它不起作用,希望有人能幫我修復它。我正在使用 DISTINCT 獲取數據并需要同時更新一些數據。它可以顯示值,但不能保存在數據庫中。例如,我將使用 DISTINCT 來獲取一些具有相同日期的數據,并且我將使用該代碼同時更改這些數據中的值。索引.php<script> window.onload = function() { $(".cal_amount").change(function() { var auto_array = {}; //Step 1- On change use The closest() method to get the all input elements value of selected element row. form_data = $(this).closest('tr').find('input, select'); //Step 2- On change Use map to store input elements value with name as key in the array. var myArray = $.map(form_data, function(element) { auto_array[element.name] = element.value; //return {name: element.name, value: element.value}; }); form_data = $(this).closest('tr').find('input,select').serialize(); $.ajax({ data: { action: 'update_price', form_data: form_data, }, url: 'updates_ok.php', type: 'post', beforeSend: function() { }, success: function(data) { if(data == 1){ alert('update sucessful')} } }); }); }; </script><script> window.onload = function() { $(".day_record").change(function() { var auto_array = {}; //Step 1- On change use The closest() method to get the all input elements value of selected element row. form_data = $(this).closest('tr').find('input, select'); //Step 2- On change Use map to store input elements value with name as key in the array. var myArray = $.map(form_data, function(element) { auto_array[element.name] = element.value; //return {name: element.name, value: element.value}; });
更改值時如何使用onchange自動更新mysql
慕工程0101907
2021-08-28 16:19:18