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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add target to this

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
US
I have this little script on page page to use Paypal --

window.onload = function( ){document.PayPalForm.submit();}

on the same page I have all the PayPal button form script

How can I have the javascript function open in target="_self"? or same page?
 
I'm not sure I'm going to answer your question correctly cause I don't understand it. But you can direct the target of the form by doing this:

Code:
document.PayPalForm.target = "_self";

[monkey][snake] <.
 
OK that doesnt seem to work is there another type of script that will automatically "submit" a form when the page (that contains the form} is loaded?
 
What happened when you used:
Code:
window.onload = function( ){document.PayPalForm.target = "_self"; document.PayPalForm.submit();}

Lee
 
To submit to the same page, you can leave the action blank. Then on that page you need something to process the submitted information rather than display the form again.

Lee
 
This is actually a page in a shopping cart - after the info is collected it displays a page with the paypal button code in a form - it uses the collected data to transfer to paypal on submit via the button.

I just wanted it to automatically submit when the page is displayed, that way the user goes straight to paypal with out stopping at the page. that's all
 
Set your form's action to the PayPal page, then at the bottom of the page use:
Code:
<script type="text/javascript">
document.PayPalForm.submit();
</script>

Lee
 
It already has the pointer to Paypal in it

see here <form target="paypal" name="_$iOrder" action=" method="post">

the cart populates paupals hidden fields with the gathered info from the users selections (fields like name, address, etc - also populates the fields on1 os1 os2 etc etc with the selections prices etc)
 
You have to use the ACTUAL form name, which appears different from your original example.

Code:
document.forms['_$iOrder'].submit();

Show us fake code, you get fake answers. Show us real code to get real answers.

Lee
 
Huh, jeez (fake code huh) I said right at the beginning I have a little script - the script says window.onload = function( ){document.PayPalForm.submit();}

and all I metioned after that was the same....

if I use it in a seperate page it works - as shown above - but if I add it to the cart - it breaks - not fake - just broken - not trying to be obtuse, just trying to work (within) the limitations of the cart code. From what I can figure it doesnt care about the forms actual name - care to see...

<form target="paypal" name="PayPalForm" action=" method="post">

<script type='text/javascript'>
<!--
window.onload = function( ){
document.PayPalForm.submit();
}
//-->
</script>

<input type="hidden" name="cmd" value="_ext-enter">
<input type="hidden" name="redirect_cmd" value="_xclick">
<input type="hidden" name="business" value="$config">
<input type="hidden" name="item_name" value="[$aList[iQuantity]] x $aList[sProduct] | Options:$aAttributes[basketList] | Date/Time Ordered:$aData[sDate]"><!-- adds volume of order -- adds last item to cart - also adds attributes if turned on, also adds date and time of order -->
<input type="hidden" name="item_number" value="$iOrder | Price:$aList[fPrice] ea | Sub Total:$aList[fSummary] | Shipping Cost:$aData[fCourierPrice] | Via: $aData[sCourier] | Comment on order: $aData[sComment]"><!-- adds last product name, order id number, price, subtotal, shipping cost and comment if entered to comment field -->
<input type="hidden" name="amount" value="$aData[fSummary]"> <!-- adds costing here -->
<input type="hidden" name="shipping" value="$aData[Delivery_cost]"> <!-- adds price of shipping -->
<input type="hidden" name="shipping2" value="">
<input type="hidden" name="currency_code" value="GBP"><!-- Sets the shipping and billing country. -->
<input type="hidden" name="first_name" value="$aData[sFirstName]">
<input type="hidden" name="last_name" value="$aData[sLastName]">
<input type="hidden" name="address1" value="$aData[sStreet]">
<input type="hidden" name="address2" value=""><!-- add fields if this is needed -->
<input type="hidden" name="city" value="$aData[sCity]">
<input type="hidden" name="state" value="$aData[sState]"> <!-- added state field to accomodate the US - remove if not neeed/used -->
<input type="hidden" name="zip" value="$aData[sZipCode]"> <!-- this could also be postcode or ....? -->
<input type="hidden" name="lc" value="UK"> <!-- Locale. This is the buyer's checkout flow language. -->
<input type="hidden" name="email" value="$aData[sEmail]"> <!-- Email address. (Max. length = 127) -->
<input type="hidden" name="no_note" value="1">
<input type="image" src="[URL unfurl="true"]http://www.paypal.com/en_US/i/btn/x-click-but06.gif";;;;[/URL] name="submit" alt="Make payments with PayPal" width="62" height="31" border="0" onClick="top.location.href='index.php?p=ordersBasket'"> <!-- added last -->
</form>
 
You're correct that Paypal doesn't care about the form's name, but for the Javascript you use on the page that's being submitted it DOES matter what you refer to the form name as. My comment about fake code was because of the form name change in the post previous to that.

If you have any server-side scripting in the example you just posted, please show ONLY client-side HTML code, the final output the browser deals with.

I have successfully set up sites to automatically submit to Paypal along the lines of what you're attempting, so I understand what you want to do.

Have you tried the page in Firefox so you can see any errors generated on the page?

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top