一次点击多个操作问题
当前页面有一个表单 要 点击一个 按钮或连接 后使当前页面输入的值插入数据库
然后自动跳转到下一个页面同时还有传一个值过去
我的做法是使用ajax传值 但是好像不行
那个高人给看看 要是有好别的的方法更好
<form id='order' name='order' method='get' action='./jiesuan.php'><table width="500" height="200" align="center" name="formt"> <tr><td>收货人:</td><td><input type="text" name="shouhuo" id="shouhuo"></td></tr> <tr><td>收货地址:</td><td><input type="text" name="address" id="address"></td></tr> <tr><td>邮编:</td><td><input type="text" name="postcode" id="postcode"></td></tr> <tr><td>电话:</td><td><input type="text" name="phone" id="phone"></td></tr> <?php $o_num=date('Ymdhis'); //生成订单号?> <tr><td> <a href="./pay.php?o_num=<?php echo $o_num ?>" name="tijiaoding"><img src="../image/tijiaoding.jpg" ></img></a> <td><input type="button" id="mys" name="mys" value="mys"></td> </tr> </table></form><script type="text/javascript"><!--function s(){ var xmlhttp = new XMLHttpRequest(); var url = "pay.php?shouhuo="+$("shouhuo").value+"&address="+$("address").value+"&postcode="+$("postcode").value+"&phone="+$("phone").value; alert("已提交"); xmlhttp.open("GET",url,true); xmlhttp.send(null); window.location.reload(); // location.href="pay.php";}$("mys").onclick = s;function $(id){ return document.getElementById(id);}//--></script><?php if($_POST){ //if($_SESSION['user']) //{ $user=$_SESSION['user'][1]; // if($_POST['shouhuo']){ $shouhuo=$_POST['shouhuo']; $address=$_POST['address']; $postcode=$_POST['postcode']; $phone=$_POST['phone']; $ding="insert into ord(o_id , o_num , coun , u_name , u_phone , u_address , postcode , ordertime , send , pay ) values('','$o_num', '$sum','$user','$phone','$address','$postcode',NOW(),'','',)"; if(mysql_query($ding,$conn)) go("pay.php"); foreach ($arr as $k=>$v){ } // } // else // echo "请输入收货信息!"; //} //else // echo "请<a href='../vip.php'>登录>></a>!";}?>
function s(){ var xmlhttp = new XMLHttpRequest(); var url = "pay.php?shouhuo="+$("shouhuo").value+"&address="+$("address").value+"&postcode="+$("postcode").value+"&phone="+$("phone").value; xmlhttp.onreadystatechange=myCallback; xmlhttp.open("GET",url,true); xmlhttp.send(null);}function myCallback(){ alert("已提交"); window.location.reload();}