Use jquery to hide the display of list forms, disable switching, and modify the content of the row submitted in Ajax mode.

Source: Internet
Author: User
Tags zend framework

Please do not pirated, reproduced please add source http://blog.csdn.net/yanlintao1

Please do not pirated, reproduced please add source http://blog.csdn.net/yanlintao1

Let's take a look at the effects of the images. You don't need to copy the Code directly. This won't work, because your database is different from mine, but you can read the code yourself and find something useful to you, of course, my method is not the best. I hope you can give me some comments. I am very grateful.

(1) Click the modify icon.


(2) Fill in the modification content


(3) Click OK to modify


Jquery and css code:

<Script language = "javascript"> $ (function () {// listener changes to implement switching between display closures $ ("tr "). delegate ("td [id = 'modify']", "click", function () {var id = $ (this ). attr ('name'); $ ("#" + id ). toggleClass ("close") ;}); // listen to the modify confirmation button and submit $ ("td") in ajax mode "). delegate ("input [name = 'Update [] ']", "click", function () {var id = $ (this ). parent (). parent (). attr ('name'); var student_id1 = $ ("input [name = 'student _ id1 ']"). map (function () {return $ (this ). val ()}). get (); Var date1 = $ ("input [name = 'date1']"). map (function () {return $ (this ). val ()}). get (); var beforeclass_id1 = $ ("input [name = 'beforeclass _ id1']"). map (function () {return $ (this ). val ()}). get (); var class_id1 = $ ("input [name = 'class _ id1']"). map (function () {return $ (this ). val ()}). get (); var type1 = $ ("select [name = 'type1']"). map (function () {return $ (this ). val ()}). get (); var remark1 = $ ("input [name = 'remark1 ']"). map (function () {Return $ (this ). val ()}). get (); $. post ("/qtsc/update", {student_id1: student_id1 [id], date1: date1 [id], role: beforeclass_id1 [id], class_id1: class_id1 [id], type1: type1 [id], remark1: remark1 [id]}, function (data) {if (data = 'class format error or does not exist, please check! ') {Alert (data) ;}else {alert (data); location. reload () ;}}) ;}) ;}</script>

Html code:

 
 <Script type = "text/javascript" src = "/js/jquery. js "> </script> <script type =" text/javascript "src ="/js/cxjl. js "> </script> <script type =" text/javascript "src ="/My97DatePicker/WdatePicker. js "> </script>MYTITLE                  "; $ K ++ ;}?>                   Add record     Delete selected     
   
Here, zend framework only writes the action in the controller. The model is omitted and the others are not important.
// Check the student's public function checkstuAction () {$ stu_id = $ this-> getRequest ()-> getParam ("stu_id"); $ Student = new student (); $ res = $ student-> getStudent ($ stu_id); $ studentchange = new Studentchange (); $ res3 = $ studentchange-> getStuchange ($ stu_id ); $ beforeclass_id = $ this-> getRequest ()-> getParam ('beforeclass _ id'); $ class_id = $ this-> getRequest () -> getParam ('class _ id'); $ classes = new Classes (); $ res1 = $ class Es-> getClassid ($ beforeclass_id); $ res2 = $ classes-> getClassid ($ class_id); if (count ($ res) = 0 & count ($ res3 )! = 0) {echo 'this student ID does not exist, or this student already exists in student status change '; exit ();} elseif (count ($ res1) = 0 | count ($ res2) = 0) {echo 'class format error or does not exist. Please check! '; Exit () ;}else {echo' OK '; exit () ;}// modify public function updateAction () {// value: $ student_id1 = $ this-> getRequest ()-> getParam ('student _ id1'); $ date1 = $ this-> getRequest () -> getParam ('date1'); $ beforeclass_id1 = $ this-> getRequest ()-> getParam ('beforeclass _ id1'); $ class_id1 = $ this-> getRequest () -> getParam ('class _ id1'); $ type1 = $ this-> getRequest ()-> getParam ('type1'); $ remark1 = $ this-> getRequest () -> ge TParam ('remark1 '); // The Name Of The converted class is ID $ classes = new Classes (); $ res1 = $ classes-> getClassid ($ beforeclass_id1 ); $ res2 = $ classes-> getClassid ($ class_id1); if (count ($ res1) = 0 | count ($ res2) = 0) {echo 'the class format is incorrect or does not exist. Please check it! '; Exit () ;}$ data = array ('student _ id' => $ student_id1, 'date' => $ date1, 'beforeclass _ id' => $ res1 [0] ['id'], 'class _ id' => $ res2 [0] ['id'], 'type' => $ type1, 'remark' => $ remark1); $ studentchange = new Studentchange (); $ db = $ studentchange-> getAdapter (); $ where = $ db-> quoteInto ('student _ id =? ', $ Student_id1); $ flag = $ studentchange-> update ($ data, $ where ); // $ date1 = array (// 'class _ id' => $ res2 [0] ['id'] //); // $ student = new Student (); // $ db1 = $ student-> getAdapter (); // $ where1 = $ db1-> quoteInto ('Id =? ', $ Student_id1); // $ flag1 = $ student-> update ($ data1, $ where1); if (count ($ flag) = 0) {echo 'You have not modified the content or the entered format is incorrect. Please check it! '; Exit () ;}else {echo' modified successfully! '; Exit ();}}

Please do not pirated, reproduced please add source http://blog.csdn.net/yanlintao1


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.