Ajax Popup + DELETE

Source: Internet
Author: User

Delete oneself Daoteng for half a day did not realize, yesterday morning and about the doctor so the teacher said did not hear ...

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">//Load jquery package, this must be placed in the first<script src= "Tanchuang.js" ></script>//Loading the popup window JS<link href= "Tanchuang.css" rel= "stylesheet" type= "Text/css"/>//CSS for loading pop-up windows<style type= "Text/css" >//Beautify "View Details", add background color. tan{background-color: #A8FFA8; color:#666;}. Tan:hover//Background color change mouse to small hand when mouse overlay {background-color: #69F; color:#666; Cursor:pointer;}</style>//Build table and table header, where Ajax is not used, PHP to display the data<tr><td> code </td><td> Car name </td><td> price </td><td> fuel consumption &LT;/TD&GT;&LT;TD > Power </td><td> operation </td></tr><?php//php Displays the data include in the car table ("ChaXun.class.php"); $db=NewChaxun (); $sql= "SELECT * FROM Car"; $attr= $dbQuery ($sql); foreach ($attr as $v) {echo"<tr> <td><div><input type= ' checkbox ' class= ' dx ' value= ' $v [0] '/> $v [0] </div></t D>//gives check box class and value, convenient for jquery with <td> $v [1]</td> <td> $v [7]</td> < ;td> $v [4]</td> <td> $v [5]</td> <td><sapn class= ' tan ' bs= ' $v [0] ' > View details </spa N></td> //Custom Properties BS </tr>";}&GT;&LT;TR&GT;&LT;TD colspan= "6" ><input type= "checkbox" id= "QX"/> Select all &nbsp;&nbsp;<input type= " Button "value=" bulk Delete "id=" Shanchu "/></td></tr></table></body><script type=" text/ JavaScript ">$ (document). Ready (function(e) {$ ("#qx"). Click (function() {//Select all varck=$ (". DX")); //Find all check boxes according to the class name varQX = $ ("#qx") [0].checked; //Convert all selected Jqery objects to the selected state of the DOM object Ck.prop ("Checked", QX);                            //jquery check box can be used prop }) $("#shanchu"). Click (function() {//delete vardx=$ (". DX")); varStr= "";  for(vari=0;i<dx.length;i++)            { if(Dx.eq (i). Prop ("checked")) ) {str+=dx.eq (i). Val () + "|"; } STR=str.substr (0,str.length-1); $.ajax ({async:false, URL:"Chuli.php", Data:{str:str}, type:"POST", DataType:"TEXT", Success:function(data) {alert (Data.trim ());                                      }                }); }                                    })            $(". Tan"). Click (function() {//pop-up windowvarcode=$ ( This). attr ("BS"); //Get primary key value $.ajax ({async:false, URL:"Tanchuang.php", Data:{code:code}, type:"POST", DataType:"TEXT", Success:function(data) {varStr= ""; varLie=data.trim (). Split ("^"); varHTML = "<div> code:" +lie[0]+ "</div> <div> car Name:" +lie[1]+ "</div> <div> Price:" +lie[2]+ "</ Div> <div> fuel consumption: "+lie[3]+" </div> <div> Power: "+lie[4]+" </div> "; varWin =NewWindow ({width:500, Height:300, Title:' Information details ', content:html, Ismask:true, buttons:"", Isdrag:true,                    });                    }      });}) });</script>

tanchaung.php

<? PHP $code=$_post["Code"]; include ("ChaXun.class.php"); $db=new  Chaxun (); $sql= "SELECT * from Car where code= ' {$code} '"; $str=$db->strquery ($sql); Echo $str;

chuli.php

<?PHPinclude("ChaXun.class.php");$db=NewChaxun ();$str=$_post["Str"];$attr=Explode("|",$str);$TJ=implode($attr,"‘,‘");$sql= "Delete from the Car where Code in (' {$TJ}‘)";if($db->query ($sql, 1)){    Echo"Delete succeeded!" ";}Else{    Echo"Delete failed!" ";}

Ajax Popup + DELETE

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.