Custom page add to cart with options |
Post Reply |
Author | |
Greg Dinger
Certified ProductCart Developers Joined: 23-September-2006 Location: United States Status: Offline Points: 238 |
Post Options
Thanks(0)
Posted: 23-September-2006 at 10:21pm |
I created this page, and the last 2 items have options for "size". I find that "add to cart" (for those 2 items, the others work fine) results in a redirect to the home page instead of adding the qty to the cart. Comparing the code to the normal detail page, I don't see a difference in terms of the form action or the input fields: Would someone mind shedding some light upon what I might be overlooking? Thanks much,
Edited by Greg Dinger - 23-September-2006 at 10:22pm |
|
Matt
Moderator Group Joined: 20-July-2006 Location: United States Status: Offline Points: 73 |
Post Options
Thanks(0)
|
You will
need to create on validation function for each form on the page, or modify the
function to receive the form's name as a parameter. For
example , the
first product with options is contained within a form named "additem6". Therefore
the function will not work unless "additem6" is part of its path.
function cdd(choice, option)
{ if
(choice== 0) {
alert ("The product cannot be added to the shopping
cart.\n"+ option + " is a required option.\n"); } else {
document.additem6.action="/store/pc/instPrd.asp";
document.additem6.method="POST";
document.additem6.submit();
} } Therefore
your next product can not use the same function "cdd", since this function only
works with the form "additem6". So if the next form on the page is
called "additem7"
you will need a new function. For a
better, more compact alternative you could just pass the name of the form into
one dynamic function. That would look something like
this: Function Call cddMulti(additem6.idOptionA.selectedIndex,'Size','additem6') ; Function function cddMulti(choice,
option, formname)
{ var
targeForm = eval("document." + formname + ""); if
(choice== 0) { alert
("The product cannot be added to the shopping cart.\n"+ option + " is a required
option.\n"); } else {
targeForm.action="/store/pc/instPrd.asp"; targeForm.method="POST"; targeForm.submit();
} } We hope
this helps! |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |