The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

javascript and buy button

RickWRickW Member
in Help edited September 2009
I'm converting over an existing site to FoxyCart. Originally I was using a OnClick, within a form to call my old shopping cart on a different page.

The new line of code doesn't work. Any suggestions? Should I use something other than "window.location"?

<input type='button' value='Buy' onClick='window.location="https://wetzelandcompany.foxycart.com/cart?name=Watercolor Background&price=79.95&category=CDs"class="foxycart"' />
Comments
  • I've tried
    onClick="https://wetzelandcompany.foxycart.com/cart?name=Watercolor Background&price=79.95&category=CDs"class="foxycart" />

    and that doesn't work either.

    goto www.wetzelandcompany.com/test.php to view the non results.
  • tookingstookings Member
    edited September 2009
    This will work...but you won't get the pop-up cart...you can use "location.href" or "parent.location" for the same results...the issue is around the way "class=foxycart" is included. Which won't work to pop-up the thickbox if you add class=foxycart outside the onClick or in the form tag, either. (There are JavaScript ways around that, but it gets a bit messy and unsupported.)
    <input value="Buy" onclick="window.location='https://wetzelandcompany.foxycart.com/cart?name=Watercolor Background&price=79.95&category=CDs'" type="button">

    Just personally, I'd probably do something like this, for the same effect, a working thickbox, and straightforward code:
    <form action="https://wetzelandcompany.foxycart.com/cart"; class="foxycart" method="post">
    <input type="hidden" name="name" value="Watercolor Background" />
    <input type="hidden" name="price" value="79.95" />
    <input type="hidden" name="category" value="CDs" />
    <input value="Buy" type="submit" />
    </form>

    Would that approach work for you?
  • I got the javascript to work, as now a separate cart page is loaded. However there isn't a "Continue Shopping" button. Is this typical?

    I had to go this route because I couldn't embed a new form within a form. It just screwed things up too much.
  • lukeluke FoxyCart Team
    Hey RickW. Is there a reason you can't use FoxyCart as is? I'm a little confused by what you mean concerning a form within a form. Can you put a FoxyCart form outside of the form you're in and do a submit() on that form via some javascript?
  • Hi Luke,
    This particular page is very complicated. Go to:
    http://www.wetzelandcompany.com/DigitalLibrary3.php?Category=Watercolor Backgrounds&Search.x=51&Search.y=13&Search=Search

    Be sure to copy the two lines as is and paste it.

    I tried creating a form after the other forms and the information that should have been passed failed. I really didn't want to rewrite what I've already done.

    On top of all of this, part two will be selling credits and using an xml feed. I'm almost done with that part, but will be asking a question or two later.
  • I've rewritten the page using the form and it works much better. I had to compromise on the layout of the page, but in the end It's much better.
  • Nice work! (I think the "buy" button jumps out at you a little more like that too.)
Sign In or Register to comment.