SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Canada
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help with JS in shopping cart

    How do I make this long story short? :-)

    I am redesigning a site with a shopping cart. I signed my client up with a hosting company that includes the EasyStoreMaker Pro shopping cart system. I designed all the pages with pretty pictures and my own Add to Cart buttons.

    Then I found out that the ESM Pro only does catalog type design. So, in my "there has to be a way" attitude, I did a mock up of a cart and pulled the code from the catalog style and put them into my pages.

    Unfortunately I am getting JS errors and can't figure out why (even after staring at it for hours on end). I think it has something to do the that 'btn' that keeps showing up.

    The page I designed is located at http://eliteva.net/dolls2.shtml (this is just an empty domain to get the shopping cart set up so none of the links in the nav work)

    Can any of you JS experts take a look at my code and tell me why I am getting errors and how I can rectify this? THERE HAS TO BE A WAY!

    Thanks all.

    Janice

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if none of the navs work as well as the 'add to cart' and 'view cart', what are we supposed to be looking at?

    What sort of error are you getting and at what line?

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    There's so many things wrong with this I don't even know where to start. Your cut and paste solution will just not work.

    1. First, your html does not have a <form> tag. In order for your add to cart js functions to work you require a <form> tag at least.
    2. When you click on a add-to-cart it calls a function and refers to an element in your form. Based on your choice it attempts to set certain values in your form elements. The errors you're getting are because these form elements do not exist!. Example:

    Code:
    <IMG SRC="Images/addtocart_small.gif" 
    VALUE="Add" 
    ONCLICK="javascript:js_activesubpage('cartadd')">
    That's the html that calls the js_activesubpage function and passes a string parameter 'cartadd'. Inside the function you have:

    Code:
    function js_activesubpage(btn) {
      document.forms[0].clickedbtn.value = 'btn';
      document.forms[0].activesubpage.value = 'btn';
      document.forms[0].target="_self";
      document.forms[0].action="/cgi-bin/online/storepro.php";
      document.forms[0].submit();
    }
    document.forms[0].clickedbtn refers to the form element with a name 'clickedbtn' in the first form tag on your page. You don't have a form tag at all, so you get an error no matter what. Second, there is absolutely no form element called 'clickedbtn'. There also is not any form element called 'activepage', 'activeproduct'(2 used in other functions) or 'activesubpage', for that matter. So your script is trying the set the values of form elements that do not exist.

    3. Your menu on the left side uses a script called 'animate.js'. What this is supposed to do, Lord only knows. If you wish to get rid of the errors for your nav menu the first thing you need to do is have the include reflect your server. Example...

    You have this in your html just before the menu starts:
    Code:
    <script language="JavaScript1.2" 
    fptype="dynamicanimation" 
    src="file:///C:/Program%20Files/Microsoft%20Office/Office/fpclass/animate.js">
    </script>
    As you can see the path refers to a your local machine, try something like: src="http://www.yourdomain.com/fpclass/animate.js"

    Fix these problems then see what happens. The main thing about the cart errors is the fact that these form elements don't exist. So refer back to the original code you copied and see what you missed.

    -xDev
    Last edited by xDev; Aug 8, 2003 at 06:02.

  4. #4
    SitePoint Member
    Join Date
    Aug 2003
    Location
    Canada
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you go to the page http://eliteva.net/dolls2.shtml and click on any of the shopping cart nav (ie. view, checkout or add to cart), I get the javascript error message at the bottom of my browser. When I double click on that to see what the error is I get a couple of errors.

    When I click on view cart or checkout, I get error on line 49 which says 'document.form.0.clickedbtn' is null or not an object.

    If I click on any of the shopping cart buttons, I get the same error but on line 58.

    Hope you can help.
    Janice

  5. #5
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by docutype
    If you go to the page

    When I click on view cart or checkout, I get error on line 49 which says 'document.form.0.clickedbtn' is null or not an object.

    If I click on any of the shopping cart buttons, I get the same error but on line 58.
    Yep, that you do. I explained to you why this is happening.

    -xDev


Bookmarks

Posting Permissions

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