TianJia.php主页
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript" src="Script/jquery-1.7.1.min.js"></script> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <input id="jian" value="-" type="button" /> <input id="text" value="1" style="width:20px;" type="text" /> <input id="jia" value="+" type="button" /> </body> <script type="text/jscript"> $(document).ready(function(e) { //数量增加按钮 $("#jia").click(function(e) { var text1= $("#text").val(); $.ajax({ url:"TianJiaDo1.php", data:{text1:text1}, dataType:"TEXT", type:"POST", success: function(data) { $("#text").val(data); } }); //数量减少按钮 $("#jian").click(function(e) { var text2=$("#text").val(); $.ajax({ url:"TianJiaDo2.php", data:{text2:text2}, dataType:"TEXT", type:"POST", success: function(data) { $("#text").val(data); } }) }); }); }); </script> </html>
TianJia.Do1数量添加处理页面
<?php $zhi= $_POST["text1"]; echo $zhi=$zhi+1; ?>
TianJia.Do2数量减少页面
<?php $text2=$_POST["text2"]; $text2; if($text2>2) { echo $text2=$text2-1; } else{echo 1;} ?>
时间: 2024-10-13 14:45:58