admin管理员组文章数量:1421000
I want to submit a form immediately when a PHP file is visited in the browser. How can I do this: Preferably in jQuery.
Details:
I have a form that once submitted inserts some data into a database and sends the user to a separate page. On the separate page, I have code for another form that then directs users to pay for whatever they have selected.
I don't want the user to have to click submit on the second form in order for them to pay. So is there a way to make that form submit automatically and thus direct the user to the payment stage?
I want to submit a form immediately when a PHP file is visited in the browser. How can I do this: Preferably in jQuery.
Details:
I have a form that once submitted inserts some data into a database and sends the user to a separate page. On the separate page, I have code for another form that then directs users to pay for whatever they have selected.
I don't want the user to have to click submit on the second form in order for them to pay. So is there a way to make that form submit automatically and thus direct the user to the payment stage?
Share Improve this question edited Apr 2, 2015 at 16:50 Eric Leschinski 154k96 gold badges422 silver badges337 bronze badges asked Oct 23, 2011 at 17:04 Alex SaidaniAlex Saidani 1,3172 gold badges16 silver badges32 bronze badges 1- 2 So why don't you redirect the user to the payment stage in the first place? – Jon Commented Oct 23, 2011 at 17:07
3 Answers
Reset to default 2Invoke the submit
method:
$("#formID").submit();
So, at your second page:
<script>
$(function(){
$("#your-formID").submit();
});
</script>
you can do this
<body onload="submitForm()" ></body>
<script>
function submitForm()
{
document.frm.submit();
}
</script>
frm is name of form
Why does that form exist if it is submitted automatically? Make the first form redirect directly to the third page and handle the rest on the server. No need to send the data to the client if it is not used there. And automatically posting using Javascript may not work on each client. Eliminate the risk by doing it server side.
本文标签: javascriptphpSubmit form on loadStack Overflow
版权声明:本文标题:javascript - PHP, Submit form on load - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745331660a2653840.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论