开发者

Set a html form with javascript

开发者 https://www.devze.com 2023-03-29 09:44 出处:网络
I\'ve been playing with the PayPal code: <form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" name=\"paypal\">

I've been playing with the PayPal code:

                <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="test@test.org">                     
                <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> 

And I want to set the value of item_name_1 and amount_1 via javascript when a button is pre开发者_运维问答ssed elsewhere so when that form is submitted the values are all set:

So I have this function run when the add to cart is clicked:

<script type='text/javascript'>
function addtocart(){                                               
paypal.item_name_2.value="Hello!"; 
}
 </script>

I feel I'm on the right tracks but no joy. Help please! TIA


Try this

document.forms["paypal"].item_name_2.value="heelo";


try this

document.forms['paypay']['item_name_2'].value = "hello";
0

精彩评论

暂无评论...
验证码 换一张
取 消