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 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆