我正在尝试在第三方网站上实施PayPal购物车。首先要求客户从下拉菜单中选择产品(“产品”),然后可选择在文本字段中输入特定金额(“附加成本”)。这两个值最终应在提交后发送给PayPal。
虽然一切都运行良好,有两个文本字段,amount_1
和amount_2
明确定义,但我很难为下拉列表的选项分配不同的值(/金额,比如说10.00和5.00)并使所选选项的值为amount_1
。这是我到目前为止所找到的代码:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="whatever@gmail.com">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="item_name_1" value="Product">
<input type="hidden" name="on0_1" value="Product">
<select name="os0_1">
<option value="product1">Product 1</option>
<option value="product2">Product 2</option>
</select>
<input type="hidden" name="item_name_2" value="Additional Costs">
<input type="text" name="amount_2" value="0.00">GBP
<br>
<br>
<input type="hidden" name="currency_code" value="GBP">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
option_select
和option_amount
似乎无法使用此类表单。任何帮助将不胜感激!
答案 0 :(得分:0)
我假设这是用于选择产品amount_1
的选择框:
<select name="os0_1">
<option value="product1">Product 1</option>
<option value="product2">Product 2</option>
</select>
您需要做的是:
<input type="hidden" name="item_name_1" value="Product" id="item_name_1">
<select name="amount_1" onchange="changeProductName()" id="amount_1">
<option value="5.00">Product that is a fiver</option>
<option value="10.00">Product that is a tenner</option>
</select>
<script>
function changeProductName() {
var e = document.getElementById('amount_1');
var h = document.getElementById('item_name_1');
h.value = e.options[e.selectedIndex].text;
}
</script>
这会将item_name_1
更改为价格选项的友方价值。