Hello,

I have a PayPal button that uses a submit button to pay, but I have a small problem with it.

The client I'm making this for also wants tracking (Hits).

Is it possible to have the submit button also run a javascript before going to paypal?

If you need the button's code, here it is. (I know it's not the most secure, but it works for the purposes):

<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"> 
		<!-- Identify your business so that you can collect the payments. --> <input type=\"hidden\" name=\"business\" value=\"".$this->getAdminEmail()."\"> 
		<!-- Specify a Buy Now button. --> <input type=\"hidden\" name=\"cmd\" value=\"_xclick\"> 
		<!-- Specify details about the item that buyers will purchase. --> <input type=\"hidden\" name=\"item_name\" value=\"$name\"> 
		<input type=\"hidden\" name=\"amount\" value=\"$prc\"> <input type=\"hidden\" name=\"currency_code\" value=\"USD\"> 
		<!-- Display the payment button. --> <input type=\"image\" name=\"submit\" border=\"0\" src=\"https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif\" alt=\"PayPal - The safer, easier way to pay online\"> 
		<img alt=\"\" border=\"0\" width=\"1\" height=\"1\" src=\"https://www.paypal.com/en_US/i/scr/pixel.gif\" > </form>

It has escapes because it is actually returned by a PHP function.

I already know the JavaScript I need to write.


---

If my idea is impossible, is it possible to create an "in between page" where a PHP page is posted to, and then posts to paypal?

---

If there is a much easier way, please let me know


--Turt2Live

Recommended Answers

All 2 Replies

On onclick event of button you can call one js function.
In js function call ajax to increment click counter.

Thats what I thought. Thank you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.