更改值时如何使用onchange自动更新mysql

我正在编辑一个应该在值更改时更新数据库的代码,但是它不起作用,希望有人能帮我修复它。


我正在使用 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};

            });

慕工程0101907
浏览 133回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP