日期:2014-05-17  浏览次数:20481 次

为什么我的表单只能提交一次
我这个表单只能提交一次,我重新选择一个时间,第二次点击提交就没反映了
<script type="text/javascript">
function checkvalid()
{
  var form=document.getElementById("date_form");
  form.submit();
}
</script>
  <div class='formrow'>
  <form id='date_form' method='post' action='/report/dailysale.php'>
  <span>Select date</span><br />
  <input style='height:25px;width:600px;' id='datepicker1' type='text' name='date' onClick='WdatePicker()' onblue='checkcitime()' />  
  <div style='width:100%;height:40px;'>
  <a onclick='checkvalid()' style='line-height:40px;text-align:center'>
  <div style='float:right;width:200px;height:40px;background-image:url("/res/next.png");font-weight:700;margin-top:100px;margin-right:50px;padding:0px;text-align:center;'>
  <span style='line-height:40px;text-align:center'>submit</span>
  </div>
  </a>
  </div>  
  </form>  
  </div>
<?php
  if(isset($_REQUEST['date']))
  {
  //$curd=date("Y-m-d");
  $curd=$_REQUEST['date'];
  $json_array1=null;
  $array1=null;
  $subtotal=0;
  $database=new db("localhost","root","19801010_zxy","zxy_hms_db");  
  $result=$database->query("","income","date='$curd'");  
  if($result)
  {
  while($row=mysql_fetch_array($result))
  {
  $subtotal=$row['rent'];
  }
   
  $array1=array("$curd",$subtotal);
  $json_array1 = json_encode($array1);
  }
   
  echo "<table>";
  echo "<tr>";
  echo "<th>date</th><th>Sales</th>";
  echo "</tr>";
  echo "</table>";
   
  echo "<div id='chart_div' style='width: 900px; height: 500px;margin:5px auto;'>";
  echo "</div>";
   

   
  }

?>

------解决方案--------------------
单凭这点代码是不可能出现你说的问题的。除非你的代码还没贴完。
------解决方案--------------------
把php代码放到该页代码的顶端,即script之前
------解决方案--------------------
因为后端代码执行完之后才轮到前端代码执行
------解决方案--------------------
探讨

因为后端代码执行完之后才轮到前端代码执行

------解决方案--------------------
建议你用Firefox的debug看看网络之间的传输
第一次点击提交按钮后的网络链接:
http://localhost/report/dailysale.php?date=……
那么在你的dailysale.php页面就会有if(isset($_REQUEST['date']))的操作被执行。
而再次刷新时的页面链接就变为:
http://localhost/report/dailysale.php
因为没有按钮提交时所获取的表单内容