Use jquery to implement the display of the hidden list form off switch and the Ajax way to modify the submission of the corresponding line of the modification content.

Source: Internet
Author: User
Tags date1 zend framework

Do not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1

Do not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1

First of all to see the picture effect, we do not directly copy the code, this is not run, because your database and I do not like, but you can read this code yourself, look for their own useful, of course, my method is not the best hope that you can give some advice, grateful.

(1) Click the Edit icon


(2) Fill in the contents of the amendment


(3) Click OK to modify


jquery and CSS code:

<style type= "Text/css" >.open{display:block;}. close{Display:none;} </style><script language= "javascript" >$ (function () {//Listen modify, implement switch between display off $ ("tr"). Delegate ("Td[id="  Modify '] "," click ", Function () {var id = $ (this). attr (' name '); $ ("#" +id). Toggleclass ("Close");}); /Listen for modified confirm Modify 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],beForeclass_id1:beforeclass_id1[id],class_id1:class_id1[id],type1:type1[id],remark1:remark1[id]},function (data) { if (data== ' class format is wrong or does not exist, please check!       ') {alert (data);        }else{alert (data);       Location.reload (); }});});}); </script>

HTML code:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">Zend Framework Here I write only the action in the controller, the model is omitted to write, the other is not important to write
Check student public Function checkstuaction () {$stu _id= $this->getrequest ()->getparam ("stu_id");        $student = new Student ();                $res = $student->getstudent ($stu _id);        $studentchange = new Studentchange ();                $res 3 = $studentchange->getstuchange ($stu _id);        $beforeclass _id = $this->getrequest ()->getparam (' beforeclass_id ');        $class _id = $this->getrequest ()->getparam (' class_id ');        $classes = new classes ();        $res 1 = $classes->getclassid ($beforeclass _id);        $res 2 = $classes->getclassid ($class _id);            if (count ($res) ==0&&count ($res 3)!=0) {echo ' This number does not exist, or the student already exists in the school student's movement ';                    Exit (); }elseif (Count ($res 1) ==0| | Count ($res 2) ==0) {echo ' class format is wrong or does not exist, please check!            ';        Exit ();            }else{echo ' OK ';        Exit (); }}//Modify Public function updateaction () {//value $student _ID1 = $this->getrequest()->getparam (' student_id1 ');        $date 1 = $this->getrequest ()->getparam (' date1 ');        $beforeclass _id1 = $this->getrequest ()->getparam (' beforeclass_id1 ');        $class _id1 = $this->getrequest ()->getparam (' class_id1 ');        $type 1 = $this->getrequest ()->getparam (' type1 ');                $remark 1 = $this->getrequest ()->getparam (' Remark1 ');        The conversion class is named ID $classes = new classes ();        $res 1 = $classes->getclassid ($beforeclass _id1);        $res 2 = $classes->getclassid ($class _id1); if (count ($res 1) ==0| | Count ($res 2) ==0) {echo ' class format is wrong or does not exist, please check!            ';        Exit (); } $data = Array (' student_id ' = = $student _id1, ' date ' = $date 1, ' before class_id ' = + $res 1[0][' id '], ' class_id ' + $res 2[0][' id '], ' type ' = + $type 1, ' remark ' =                > $remark 1);        $studentchange = new Studentchange (); $db = $studentchange-> Getadapter ();        $where = $db->quoteinto (' student_id=? ', $student _id1);        $flag = $studentchange->update ($data, $where); $date 1 = Array (//' class_id ' = = $res 2[0][' id ']//);//$student = new Student () ;//$db 1 = $student->getadapter ();//$where 1 = $db 1->quoteinto (' id=? ', $student _id1);//$f          Lag1 = $student->update ($data 1, $where 1); if (count ($flag) ==0) {echo ' You have not modified the content or filled in the wrong format, please check!            ';        Exit (); }else{Echo ' modified successfully!            ';        Exit (); }            }

do not pirated, reproduced please add the source Http://blog.csdn.net/yanlintao1


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.