设置使用javascript
问题描述:
我一直在玩的贝宝代码HTML表单:设置使用javascript
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="paypal">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name_1" value="Item1">
<input type="hidden" name="amount_1" value="1.00">
<input type="hidden" name="item_name_2" value="Item2">
<input type="hidden" name="amount_2" value="2.00">
<input type="submit" value="PayPal">
</form>
而且我想,所以当这种形式是当按钮被按下的其他地方通过JavaScript设置ITEM_NAME_1和amount_1的价值提交的值都设置:
所以我有这个功能运行单击Add到购物车的时候:
<script type='text/javascript'>
function addtocart(){
paypal.item_name_2.value="Hello!";
}
</script>
我觉得我在正确的轨道,但没有喜悦。请帮助! TIA
答
试试这个
document.forms["paypal"].item_name_2.value="heelo";
答
试试这个
document.forms['paypay']['item_name_2'].value = "hello";
感谢两个答案! –