1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

javascript used in a shopping cart site

Discussion in 'Software Development' started by dontgiveup, Jun 20, 2002.

Thread Status:
Not open for further replies.
Advertisement
  1. dontgiveup

    dontgiveup Thread Starter

    Joined:
    Jun 19, 2002
    Messages:
    1
    The webhost for this shopping cart site creates the codes needed to make it work on a separate page for each item. I copied the codes for each individual product and pasted them onto one page.
    Each item contains a form with hidden fields that consists of the product's id # so that the shopping cart processor should know which item is being purchased when the buy button is being clicked.
    However, the different products are not being recognized on the page, but rather, every buy button interprets as if the first item on the page is being purchased again and again.
    Being that I'm not familiar with javascripts, I don't know how to format this page so that the buy buttons for each individual item sends the right info. One thing that I did learn is that 2 forms one 1 page cannot have the same form name so I altered the name of the 2nd form to celectvar as opposed to selectvar (the default name given by the webhost).

    Following is a clipping of the scripts and forms for the 2 first products on the page.

    PHP:
    <script> function validateSelect() {    
     var 
    els document.selectvar.elements;
     for (var 
    i=0i<els.lengthi++){
       var 
    el=els[i];
       if(
    el.type != 'select-one') continue;
       if(
    el.name.indexOf('VAR_V') != 0) continue;
       var 
    val els[el.name].selectedIndex;
       if(
    el[val].value != '') continue;

       
    // inform them of an error
       
    alert('Please select a product option from the "'+el[0].text+'" menu.');
       return;
     }
     
    document.selectvar.submit();
    }

    </script>

    <FORM name="selectvar" METHOD=POST ACTION="/cgi-bin/sb/cart">
            <INPUT TYPE=HIDDEN NAME=cartclass VALUE="81001-A">
            <INPUT TYPE=HIDDEN NAME=objid VALUE="74">
            <INPUT TYPE=HIDDEN NAME=id VALUE="74">
            <INPUT TYPE=HIDDEN NAME=add VALUE=1>
    </FORM>



    <script>
    function validateSelect() {    
     var els = document.celectvar.elements;
     for (var i=0; i<els.length; i++){
       var el=els[i];
       if(el.type != 'select-one') continue;
       if(el.name.indexOf('VAR_V') != 0) continue;
       var val = els[el.name].selectedIndex;
       if(el[val].value != '') continue;

       // inform them of an error
       alert('Please select a product option from the "'+el[0].text+'" menu.');
       return;
     }
     document.celectvar.submit();
    }

    </script>
     
    <FORM name="celectvar" METHOD=POST ACTION="/cgi-bin/sb/cart">
            <INPUT TYPE=HIDDEN NAME=cartclass VALUE="81001-A">
            <INPUT TYPE=HIDDEN NAME=objid VALUE="120">
            <INPUT TYPE=HIDDEN NAME=id VALUE="120">
            <INPUT TYPE=HIDDEN NAME=add VALUE=1>
    </FORM>
    You can check out the default webhosting page that contains an individual item: http://www.organicbakeshoppe.com/rugalach.html and the page where I'm putting all products together (and that isn't working properly: http://www.organicbakeshoppe.com/cookies.htm The 2 products being coded are the black and white cookies and the rugalach
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    So what is your question exactly?? They have bad coding on their site and are only going to be selling black & white cookies. They should have tested the pages before they put them on the internet.....poor business decision.
     
  3. Snake~eyes

    Snake~eyes

    Joined:
    Apr 18, 2002
    Messages:
    640
    ahhhhhh you broke th eforums

    you tryed to post your javascript...

    Edit your post and put the javascript in php

    CLick the little php button

    that'll fix that :D
     
  4. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    I think the problem is in either your cgi or the page that is displaying the items in the shopping cart.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/84067

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice