Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PayPal button is posting to the parent page not PayPal 1

Status
Not open for further replies.

AlaskanDad

Programmer
Mar 1, 2002
188
US
I've got a PayPal button that I'm trying to get to work on two of my ASP pages.

On one page, when the button is clicked, the user is taken to PayPal to give me money (a good thing:)). On the other page, the button simply posts to the page it is on.

Here is the code for the function:
Function BasicBuyNow (MemID,Product,Amt)

Response.write &quot;<form action=' method='post'>&quot;
Response.write &quot;<input type='hidden' name='cmd' value='_xclick'>&quot;
Response.write &quot;<input type='hidden' name='business' value='subscriptions@myrealdomain.com'>&quot;
Response.write &quot;<input type='hidden' name='item_name' value='&quot; & Product & &quot;'>&quot;
Response.write &quot;<input type='hidden' name='item_number' value='&quot; & MemID & &quot;'>&quot;
Response.write &quot;<input type='hidden' name='amount' value='&quot; & Amt & &quot;'>&quot;
Response.write &quot;<input type='image' src='images/PayPalBuyNow.gif' border='0' name='submit' alt='Make payments with PayPal - fast, free and secure!'>&quot;
Response.write &quot;</form>&quot;

End Function

When I call it from the &quot;good&quot; page, I use this:

BasicBuyNow Session(&quot;MembersNumber&quot;),&quot;Buy One Please&quot;,9.95

on the &quot;bad&quot; page, I use this:

BasicBuyNow Session(&quot;MembersNumber&quot;),&quot;Bulk Update&quot;,3.95


In thinking through the differences between the two pages, I come up with this:
1. Both pages use <form method='Post'> and the called function makes a second form within it.
2. The button on the &quot;good&quot; page is in a <TD> by itself while the &quot;bad&quot; page has it in a <TD> with some text.

Any idea why one works and the other doesn't?

Thanks,
Rob
 
If I am understanding you correctly you aere ending up with nested forms. Generally this won't work or will provide strange results, try removing the outer form and only using the one that you create with your function, or leave the bottom end form tag off if you need to add more fields to the form. Text vs no text in a td should not concern the form or cause it to malfunction. Let us know how you fare without nested forms, or of I misinterpreted, please correct my ignorance :)
-Tarwn The three most dangerous things in the world are a programmer with a soldering iron, a hardware type with a program patch, and a user with an idea
-computer saying (Wiz Biz - Rick Cook)
 
I do have nested forms. On the &quot;bad&quot; page, I have a need for the whole page to be on a form but the &quot;good&quot; page only has this button.

On the &quot;bad&quot; page, there is one field above the button and a score of them below. What would happen if I eliminated the </form> from my function?

In effect, I would have two <form method...>'s and only one </form> on the page.
 
You can only submit a dingle form at a time, therefore there is no need to nest your forms as no matter what you will not be able to submit all of the form information. Perhgaps you should eliminate both the begin and end form tags from your function and depend on the form tags you are writing into your code (right now the outside ones) to submit the page. This way you will have the fields from your function as well as the rest of the fields on the page.
-Tarwn The three most dangerous things in the world are a programmer with a soldering iron, a hardware type with a program patch, and a user with an idea
-computer saying (Wiz Biz - Rick Cook)
 
On the &quot;bad&quot; page, the two form tags send the fields to different places.

The first tag records all of the fields that are supposed to be collected from the page. The second tag only records the hidden fields as shown in the function above. That tag should go to PayPal.com.

Y'know. Nevermind... The function places several hidden fields in my bigger form and that will throw off my save routines. I just need to eliminate that button from that page altogether.

Thanks for the insights anyway. I'm dropping a star on you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top