dtcd27183 2014-06-03 18:21
浏览 20
已采纳

javascript调用提交回发

I've read a lot of googling forums, but my simple sample still doesn't work. That is why I ask you to help me with my prob. I have page1 and page 2. I also have for debugging button (submit) in page1 and page2 with function header($direct). This part works and I have full understanding. But I cann't call full postback via javascript function. I don't know where is my fault. This is my union code for page1:

<?php
if (isset($_POST['btn']))
{
   header('Location: page2.php');
}
elseif (isset ($_POST['btn2']))
{
   header('Location: page2.php');
}
?>

<h1>This is page 1</h1>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
   <input type="submit" name="btn" value="submit: goto page2"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="btn2" id ="btn2" value="button: goto page2" onclick="postback();" />
</form>

<script type="text/javascript">
   function postback(){
 var f = document.getElementById('form1');
f.submit();
   }
</script>



I want to call full postback without ajax because with ajax I have no problems. In last example I tried to call javascript postback with selection object and I couldn't any problems with it. But now, when I try to use simple button onclick event it still doesn't work. why? I hope you understand my English and point me to my faults. Thank you in advance

  • 写回答

3条回答 默认 最新

  • dsfdgdsfd23212 2014-06-03 18:53
    关注

    input type button will not show value in post

    if you want to pass anything into post try input type=hidden

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序