Jquery reads data from the table on the page to generate batch insert code and sends it to the background in ajax mode.
The table format is more common. The first behavior field contains the following behavior data. The table id is detailList.
$ ("# SubmitExcel "). click (function () {// bind the insertStr = "insert into funddetail values"; // the initial value of the insert string $ ("# detailList tr: gt (0 )"). each (function (I) {// obtain all rows of the table except the first row, and add the insertStr + = "(null ,"; // continue adding the insert string $ (this ). find ('td '). each (function (j) {// obtain all columns contained in the current row, and add a method to each column (that is, each cell, I is the sequence number in the column if (j = 7) // Since each row is a Form Control in column 7th, use different methods to obtain the value {insertStr + = $ (this ). find ('select '). val () + ","; // continue adding the insert string} else {insertStr + = "'" + $ (this ). text () + "'," // Add the insert string. Note that there is a comma at the end.}) insertStr = insertStr. substring (0, insertStr. length-1); // Delete the last comma insertStr + = "),"; // set the end of the insert statement for the current row, with a comma, to facilitate the next row of Data}) insertStr = insertStr. substring (0, insertStr. length-1); // delete the comma at the end of the final insert string // use ajax to pass the preceding insert string to the background page for processing $. ajax ({type: "post", data: {insertstring: insertStr}, dataType: 'html ', url: "phpCode/saveExcel. php ", success: function (data) {alert (data );}});});