Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    1
    Thanks
    0
    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:

    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:

    Code:
    <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>
                                </div>
    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 HELP, PLEASE!?

    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
    Posts
    27,613
    Thanks
    80
    Thanked 4,634 Times in 4,596 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.

    ANYWAY...

    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
    •