Use jquery to enable the display of the hidden list form to switch off and change the way the Ajax method commits the corresponding line.

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 executable, because your database and I are not the same, but you can read this code yourself. Looking for their own practical, of course, my method is not the best hope that we can give some advice. Appreciate.

(1) Click the Change icon


(2) Fill in the contents of the changes


(3) Click OK to change


jquery and CSS code:

<style type= "Text/css" >.open{display:block;}. close{Display:none;} </style><script language= "javascript" >$ (function () {//listener changes, implementation of switching between display off $ ("tr"). Delegate ("Td[id="  Modify '] "," click ", Function () {var id = $ (this). attr (' name '); $ ("#" +id). Toggleclass ("Close");}); /monitor changes to confirm the Change button and submit the $ ("TD") in Ajax. 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 just write the action in the controller. The model omits to write, the other unimportant also does not 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 is malformed or does not exist. Please check!

'; Exit (); }else{echo ' OK '; Exit (); }}//Change Public function updateaction () {//value $student _ID1 = $this->getrequest ()->getparam (' Stude Nt_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 is malformed 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 ' and $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);//$flag 1 = $student->update ($data 1, $where 1); if (count ($flag) ==0) {echo ' You have not changed the content or filled in the wrong format, please check! '; Exit (); }else{echo ' changed successfully. '; Exit (); } }


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


Use jquery to enable the display of the hidden list form to switch off and change the way the Ajax method commits the corresponding line.

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.