一种形式,一个提交按钮,但两个动作 [英] One form, One submission button, but TWO actions
问题描述
我有一个收集客户信息的表单,然后将它们保存到数据库中
$ b
-
- 发送少量电子邮件
- 将信息发送至SalesForce(SF)部门
现在,前两项任务很简单,但第三项任务给我带来麻烦。对于SF我没有做任何特别的事情,只需添加他们的网址,他们将从表格中提取出他们需要的所有必要信息。对我来说,似乎为了做到这些我需要的形式有2个行动与一个提交按钮相关联(不能有2个窗体或2个按钮)。
所以在我的 raf.php
文件中我有这个表单,提交后我必须将它们重定向到 raf-submitted.php
页面,显示成功/错误消息和其他必要信息。
表格(从 JavaScript: 这不起作用。我也试过这些没有运气: 有人可以帮我吗?谢谢! 一旦表单被提交,您就不再在该页面上。您已经导航了。 另一种方法是通过AJAX提交第一个动作,然后将表单自然提交到第二个目标。我建议使用jQuery来进行AJAX调用,因为大多数AJAX代码已经在那里供您使用。 另一个选项是让 I have a form that collects client's info and then it Now, the first 2 two task was easy, but the third one is giving me trouble. For SF i don't have do anything special, just have to add their url and they will pull out all the necessary info they need from the form. To me it seems like in order to do these i need the form have 2 actions associated with one submit button (can't have 2 forms or 2 buttons). So in my The form (got the idea from here) The JavaScript: The It's not working. I also tried these with no luck: Can someone please help me? Thank you! Once a form is submitted, you are no longer on that page. You've navigated away. The other way you can do this is submit the first action via AJAX, then submit the form naturally to the second destination. I would suggest using jQuery to make your AJAX calls since most of the AJAX code is already there for you to use. Another option is to have 这篇关于一种形式,一个提交按钮,但两个动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
< form id =referralFormname = referralFormautocomplete =offenctype =multipart / form-datamethod =POST>
< input id =saveFormname =saveFormclass =field-submittype =buttonvalue =Submitstyle =padding-left:20pxwidth = 100tabindex =23onclick =FormSubmission(); SalesForceSubmission(); />
< / form>
$(document).ready(function()
{
函数SalesForceSubmission()
{
document.referralForm.action =https://someAddress.salesforce.com/;
document.referralForm.submit();
返回true;
}
函数FormSubmission()
{
document.referralForm.action =raf-submitted.php;
document.referralForm.submit();
return true;
}
});
raf-submitted.php
档案取关心表单验证,数据库插入和电子邮件问题。
raf-submitted.php
一旦它接收到表单数据,就从您的服务器执行POST到salesforce服务器。请参阅:在PHP脚本中发布到另一个页面
raf.php
file I have this form, and after submission i have to redirect them to raf-submitted.php
page that displays the success/error message and other necessary info. <form id="referralForm" name="referralForm" autocomplete="off" enctype="multipart/form-data" method="POST">
<input id="saveForm" name="saveForm" class="field-submit" type="button" value="Submit" style="padding-left:20px" width="100" tabindex="23" onclick="FormSubmission(); SalesForceSubmission();" />
</form>
$(document).ready(function()
{
function SalesForceSubmission()
{
document.referralForm.action = "https://someAddress.salesforce.com/";
document.referralForm.submit();
return true;
}
function FormSubmission()
{
document.referralForm.action = "raf-submitted.php";
document.referralForm.submit();
return true;
}
});
raf-submitted.php
file take cares of the form validation, database insertion and email issues. raf-submitted.php
perform a POST from your server to the salesforce server once it receives the form data. See: Post to another page within a PHP script