[英]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.