Do I need to re-open the page to modify the website background data? No, use the following method to implement: html code: & lt; tablename & quot; unit & quot; border1 & gt; & lt; volistname & quot; u_list & quot; id & quot ;...
Do I need to re-open the page to modify the website background data? No, use the following method to implement it:
Html code:
- // Use the ID here to obtain the ID field in the data table
- {$ Vo. u_name}
-
- {$ Vo. href}
-
- [Delete]
-
-
-
-
- {$ Page}
-
-
JQuery code:
- $ ("Tr> td"). dblclick (function (){
- Var inval = optional (this).html (); // obtain the original content
- Var inname = $ (this). attr ("name"); // Obtain the name value in the html code, that is, the field in the data table.
- Var inid = $ (this). parents (). attr ("id"); // obtain the ID of the data to be modified
- // Alert (inval );
- Certificate (this).html (" "); // Put the original content here
- $ ("# Edit"). focus (). live ("blur", function (){
- Var editval = $ (this). val ();
- $ (This). parents ("td" pai.html (editval );
- $. Post ("save", {id: inid, ziduan: inname, val: editval}); // submit data to Action through the POST method in the AJAX method of JQ
- });
- });
The Action code in ThinkPHP:
- Calss UnitAction extends Action {
- Function save (){
- $ Id = $ _ POST ['id'];
- $ Ziduan =$ _ POST ['ziduany'];
- $ Val = $ _ POST ['Val'];
- $ U_info = M ('unit ');
- $ U_info-> where ('Id = '. $ id)-> setField ($ ziduan, $ val)-> save ();
- }
- }
- ?>
A low-level error occurs during processing, that is, in the final Action:
- Calss UnitAction extends Action {
- Function save (){
- $ Id = $ _ POST ['id'];
- $ Data ['U _ name'] =$ _ POST ['U _ name'];
- $ Data ['href '] = $ _ POST ['href'];
- $ U_info = M ('unit ');
- $ U_info-> where ('Id = '. $ id)-> save ($ data );
- }
- }
- ?>
I replaced the specific field value so that I could not modify it. Fortunately, I found this error in time and corrected it. I recorded it for reference.