简体   繁体   English

如何将表单提交到两个不同的页面(不是同时)?

[英]How can I submit a form to two different pages (not at same time)?

I need to submit a page to two pages depending on which button is triggering the submit. 我需要将页面提交到两个页面,具体取决于触发提交的按钮。 Both pages needs to be able to pick up the $_POST data being sent. 两个页面都需要能够获取正在发送的$ _POST数据。 This is what I have so far, but it's not working. 这是我到目前为止所做的,但它不起作用。

<form name="user" action="" method="POST">
  <textarea name="tname" id="tname"></textarea>
  <input type='button' value='Submit'
    onclick="document.user.action='edit.php'; document.user.submit(); this.form.target='_self'; return true;">
  <input type='button' value='Preview'
    onclick="document.user.action='preview.php'; document.user.submit(); this.form.target='_blank'; return true;">
</form>

Both pages are opening in the same window (preview button should be opening in a new window). 两个页面都在同一个窗口中打开(预览按钮应该在新窗口中打开)。

Setting the target the same way you set the action, and setting it before you submit the form works for me: 设置目标与设置操作的方式相同,并在提交表单之前设置它对我有用:

<form name="user" action="" method="POST">
<textarea name="tname" id="tname"></textarea>
<input type='button' value='Submit'
       onclick="document.user.action='edit.php'; document.user.target='_self'; document.user.submit(); return true;">
<input type='button' value='Preview'
       onclick="document.user.action='preview.php'; document.user.target='_blank'; document.user.submit(); return true;">
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何同时提交两种不同的表格? - How can i submit two different forms at the same time? 如何将表单提交到两个不同的页面 - How to submit the form to two different pages 如何通过1个提交按钮将html / php代码定向到两个不同的页面? - How can I get my html/php code to direct to two different pages from 1 submit button? 如何向两个PHP处理器页面提交表单? - How do I submit a form to two PHP processor pages? 如何在一个HTML表单中处理两个不同的提交按钮? - How can I process two different submit buttons in a single HTML form? 如何使用表单中的一个按钮提交两个不同的值? - How do I submit two different values with a single button in the form? 如何根据单击的按钮将表单提交到两个不同的页面,没有 javascript - How to submit a form to two different pages depending on the button clicked, without javascript 我怎样才能在同一页的两个不同附件形式中获得新的form.vars.id? - How can i get new form.vars.id in same page two different attachment form? 需要后如何提交表单并保持在同一页面上? - How can I submit form and stay on the same page after require? 如何同时刮取两个不同的东西并将其存储在MySQL数据库中 - How can I can scrape two different things at the same time and store it in MySQL database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM