我有一个页面使用 Paypal Payments Standard 与"buy one now"按钮在许多产品,如此 .
<form id="form1" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" name="submit2" align="right" src="https://www.paypal.com//en_US/i/btn/sc-but-03.gif" alt="Make payments with PayPal - it's fast, free and secure!" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="business" value="email@gmail.com" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="lc" value="US" />
<input type="hidden" name="return" value="http://domain.com/confirm.html" />
<input type="hidden" name="cancel_return" value="http://domain.com" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="bn" value="PP-ShopCartBF" />
<input type="hidden" name="amount" value="5.00" />
<input type="hidden" name="item_name" value="A009" />
</form>
对于每个只更改表单ID和产品编号的产品,在页面下方重复上述代码 . 在这种情况下,所有产品都是相同的价格 .
在jQuery之前,我会把所有重复的部分都放在SSI中 .
但是,现在我正在学习jQuery,我想将所有内容减少到文本链接而不是PayPal按钮,并将产品编号嵌入链接中 . 如果可能,此链接不在任何表单标记之间 .
<a class="cartBuy" href="#" id="A009">Add to Cart</a>
我知道我可以选择这样的链接......
$('.cartBuy a[id]')
但是现在我必须为每个产品都有一个独特的形式......每个产品只需一个链接,让一个脚本构建一些提交的内容(通过ajax?) . 我查看了jQuery Form Plugin但是我仍然需要在一个独特的表单元素中包含所有项目 . 我还看过让jQuery为每个表单编写所有HTML,但这与我之前使用SSI所做的事情并没有太大的不同 .
(这些是"buy one now"链接,因此无需跟踪多个选择...只需要一次提交每个选项 . )
Thank-you!
ANSWER:
我使用了Josh Leitzel的下面的答案 .
-
我在页面上包含一个表单元素,其中包含所有内容共有的所有隐藏输入元素 .
-
我完全删除了表单中的提交按钮,因为它不需要 .
-
我在item_name的一个表单中添加了一个隐藏的输入元素,其中包含空值 .
1 回答
你这样做的方法是点击链接时从链接中选择引用ID,将其写入相应的表单
input
,然后提交表单: