Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Thanked 0 Times in 0 Posts

    PLS HELP! onClick won't work after display switch

    This is driving me crazy!

    So I'm using a javascript file to switch out items when a thumbnail is clicked. This includes photo, title, description, price, size, quantity and add to cart button....

    The original code on the html file works fine, but as soon as it is swapped by onclick, the 'add to cart' button does nothing!

    Here is the code:

    var addDisplay = document.getElementById('cart-add');
    	addDisplay.innerHTML = "<a class='item_add' href='/' onclick='simpleCart.add(); return false;'><img src='images/shop/cart-add.jpg' width='118' height='26' border='0'></a>";
    that is what shows in my javascript file...

    here is what's on the html file:

    <div id="cart-add"><a class='item_add' href='/' onclick='simpleCart.add(); return false;'><img src="images/shop/cart-add.jpg" width="118" height="26" border="0"></a>
    and that adds the item to the cart just fine, but when a thumbnail is clicked on, activating the javascript file to switch out the item/elements, the 'add to cart' button no longer does anything... by the way, I am using simpleCart.js


    Please PM me if you need more info... or post here if you have a solution. Thanks!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,745 Times in 4,707 Posts
    I'm beginning to believe that simpleCart.js was invented to cause tons of people to lose lots of time finding all the problems. It's neither simple (internally) nor particularly well written, by today's standards.


    I have no idea what you mean by "swapped out" since the code being "swapped in" there is identical to what's already in place.

    Can you show this live on a test site???
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts