为什么我的提交按钮不适用于此代码?

时间:2017-03-07 21:18:43

标签: javascript jquery html forms paypal

我正在制作PayPal结帐表单。在一个页面上,它的效果非常好。它需要信息并在提交时打开PayPal而没有任何问题。但是,我将此代码放在另一个页面上,但它不起作用。当我点击按钮时,没有任何反应。代码是一样的!我甚至复制了页面,但它不适用于复制的版本。

你知道为什么吗?我很难过!

这是我的代码(请注意我使用“xxxx”代替个人信息):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="paypal"><input name="cmd" type="hidden" value="_cart" />
<input name="business" type="hidden" value="xxxx" />
<input name="item_name" type="hidden" value="xxxx" />
<input name="item_number" type="hidden" value="xxxx" /></form>
<table>

<tbody>
<tr>
<td>Name of Attendee(s)</td>
<td><input name="on1" type="hidden" value="Name of Attendee(s)" />
<input maxlength="200" name="os1" type="text" /></td>
</tr>
<tr>
<td>Ticket Type</td>
<td><input name="on0" type="hidden" value="Ticket Type" />
<select name="os0">
<option value="Single Ticket">Single Ticket - $50.00</option>
<option value="Double Ticket">Double Ticket - $100.00</option>
</select>
<!-- Specify the price that PayPal uses for each option. -->
<input name="option_index" type="hidden" value="0" />
<input name="option_select0" type="hidden" value="Single Ticket" />
<input name="option_amount0" type="hidden" value="50.00" />
<input name="option_select1" type="hidden" value="Double Ticket" />
<input name="option_amount1" type="hidden" value="100.00" /></td>
</tr>
<tr>
<td></td>
<td><input alt="PayPal The safer, easier way to pay online." name="submit" src="images/btn_cart_LG.gif" type="submit" value="Continue to PayPal" /></td>
</tr>
</tbody>
</table>
<input name="image_url" type="hidden" value="" />
<input name="return" type="hidden" value="xxxx" />
<input name="cancel_return" type="hidden" value="xxxx" />
<input name="cn" type="hidden" value="optional instructions" />
<input name="currency_code" type="hidden" value="USD" />
<input name="no_note" type="hidden" value="1" />
<img style="display: none ! important;" hidden="" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" alt="" width="1"         height="1" border="0" />
<input name="add" type="hidden" value="1" />

</form>

</body>
</html>

1 个答案:

答案 0 :(得分:4)

这一行:

<input name="item_number" type="hidden" value="xxxx" /></form>

您之前关闭了表单标记,只需删除此标记即可正常工作。

测试用例:https://jsfiddle.net/1hj4v81p/