1

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="[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> 

And I want to set the value of item_name_1 and amount_1 via javascript when a button is pressed 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

0

2 Answers 2

1

Try this

document.forms["paypal"].item_name_2.value="heelo";
Sign up to request clarification or add additional context in comments.

Comments

1

try this

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.