One view cart FORM per page. |
home page std.css |
In the PayPal shopping cart button factory a "view cart" FORM complete with graphic button is built for you.
This has some implications that some users may not appreciate. Besides the FORM code being repeated, the separate FORM means that the "view" button must appear by itself and cannot be included inside the "add to cart" FORM.
In the simple example below notice that the view cart button appears right in the middle of the cart FORM. You cannot do this with the default PayPal buttons. With this technique you may place the view cart button anywhere on an HTML page you want, and have only one copy of the FORM. And the button may be a graphic, text - anything you can click on, provided your browser supports the onclick event handler for that object. Note - NN4.n does not support the onclick EH for the <img tag! You must use an <input type="image" statement to make it work...
The way it works is to create a single "view" FORM, and then use the onclick event handler from the clickable object to remotely execute the "view" FORM. Here is one way to execute the FORM from within another FORM...
<input type = "image"
src = "viewcart.gif"
alt = "cart view"
onclick="document.forms.viewcart.target = 'paypal';
document.forms.viewcart.submit ();
return false;" />
Right-click on this page, and <view source> to see what I did.
PS - The code looks a little different from what PayPal gives you because I have modified it to make it validate under XHTML 1.1 Strict rules. See Validating under XHTML 1.1 for details of what I did. There is one violation (using a FORM name), but that is required for older browsers.
Contact me concerning this article at
paypalhelper@aol.com.
Mention "view form" in your note.
Individual help starting at $25.00 for simple JS solutions.