Javascript - 表单提交不起作用 [英] Javascript - form submit not working

查看:121
本文介绍了Javascript - 表单提交不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



this is the code that isn't working:

<form id="paypal" name="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_parent" />Official website!
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="bn" value="PP-DonationsBF">
<input type="hidden" name="currency_code" id="currency_code" value="GBP" >
<input type="hidden" name="business" id="business" value="paypalemail@null.com" >

<a href="javascript: donate(paypal);" class="button1"><span></span><strong>£<input name="amount" type="text" id="ppAmount" style="text-align:center;" value="5" size="2" /> Donate!</strong></a>
<input type="submit">
</form></span>
<div id="formtesting"></div>
<script type="text/javascript">

function donate(paypal) {

document.getElementById("formtesting").innerHTML="maybe...";
document.forms["paypal"].action = "https://www.paypal.com/cgi-bin/webscr";
document.forms["paypal"].submit();
document.getElementById("formtesting").innerHTML="did it work?";

}

我希望它在点击button1时提交,使用javascript:donate(paypal)提交按钮工作正常..
(它在formtesting div但不是did it work?:/)

I want it to submit when clicking on "button1", using "javascript: donate(paypal)" the submit button works fine.. (it prints "maybe" in the formtesting div but not "did it work?" :/)

推荐答案

使用此代码它将起作用

function donate() {
document.getElementById("formtesting").innerHTML="maybe...";
document.paypal.action = "https://www.paypal.com/cgi-bin/webscr";
document.paypal.submit();
document.getElementById("formtesting").innerHTML="did it work?";
}

这里的paypal是表单的名称。

Here paypal is name of the form.

这篇关于Javascript - 表单提交不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆