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
    Oct 2005
    Location
    California
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile ?'s About JavaScript cart

    Greetings,

    I found an example of a JavaScript shopping cart online and changed the values to fit my need, the problem that I am having is that when I get the subtotal, I want it to be displayed also in a box below were I can use just press evaluate on the calculator I made and the calculation takes place. it is the only thing I need to finish my project. if any one can help solve this problem I would really appreciate it. thanks
    here is the 1st page just click "add to quote" the click the "quote" on the bottom.
    http://www.vortexah.com/test/page1.htm

    the next page will show the table made by the cart and my question about the "subtotal"
    thanks

    This is where i think the problem in the code is:
    Code:
    function WriteToForm() {
            NumberOrdered = 0;
            Total=0;
            TOTotal=0;
            TOquantity = " ";
            TOprice = " ";
            TOid_num = " ";
            TOname = " ";
            NumberOrdered = GetCookie("NumberOrdered");
            whattowrite = "";
    
            for (i = 1; i <= NumberOrdered; i++) {
                    NewOrder = "Order." + i;
                    database = "";
                    database = GetCookie(NewOrder);
    
                    Token0 = database.indexOf("|", 0);
                    Token1 = database.indexOf("|", Token0+1);
                    Token2 = database.indexOf("|", Token1+1);
    
                    fields = new Array;
                
                    fields[1] = database.substring( Token0+1, Token1 );
                    fields[2] = database.substring( Token1+1, Token2 );
                    fields[3] = database.substring( Token2+1, database.length );
    
                    Total = Total + (fields[1] * fields[0]);
                    TOTotal = moneyFormat(Total);
    
                    document.write("<input type=hidden name=\"ID_"+ i +"\" value=\"" + fields[2] + "\">");
                    document.write("<input type=hidden name=\"NAME_"+ i +"\" value=\"" + fields[3] + "\">");
                    document.write("<input type=hidden name=\"PRICE_"+ i +"\" value=\"" + fields[1] + "\">");
                    
            }
    }

    I have set the code below(var subtotal = document.calc2.loan2.value; ) to equal the above code ( TOTotal = moneyFormat(Total); ) and i have set it to write to that filed. an i cant get it to work


    Code:
    function showpay2() {
     if ((document.calc2.loan2.value == null || document.calc2.loan2.value.length == 0) ||
         (document.calc2.doc.value == null || document.calc2.doc.value.length == 0)
    ||
         (document.calc2.rate2.value == null || document.calc2.rate2.value.length == 0))
     { document.calc2.total.value = "Incomplete data";
     }
     else
     {
    
     var subtotal = document.calc2.loan2.value;
     var dmv  = document.calc2.dmv.value; 
     var doc  = document.calc2.doc.value;
     var down  = document.calc2.down.value;
     var grand  = document.calc2.grand.value;
     var downp  = document.calc2.downp.value;
     var tax  = document.calc2.rate2.value;
     var Warranty = document.calc2.war.value;
         
     document.calc2.tax.value = Math.round (((eval(eval((eval(document.calc2.loan2.value))+ eval(document.calc2.doc.value))*(document.calc2.rate2.value ))))*100)/100;
     document.calc2.grand.value = Math.round (((eval(eval((eval(document.calc2.loan2.value))+ eval(document.calc2.doc.value))*(document.calc2.rate2.value )) + eval(eval(document.calc2.loan2.value) + eval(document.calc2.dmv.value)+ eval(document.ca
    
    lc2.doc.value)+ eval(document.calc2.war.value))))*100)/100;
     document.calc2.down.value = Math.round (((eval(eval(eval(document.calc2.grand.value) - eval(document.calc2.war.value))*eval(document.calc2.downp.value))))*100)/100;
     document.calc2.total.value = Math.round (((eval(eval((eval(document.calc2.loan2.value))+ eval(document.calc2.doc.value))*(document.calc2.rate2.value )) + eval(eval(document.calc2.loan2.value) + eval(document.calc2.dmv.value)+ eval(document.calc2.doc.value)))-eval(document.calc2.down.value)-eval(document.calc2.down2.value)+ eval(document.calc2.war.value))*100)/100;
     }
    Last edited by Rave_fxz; 10-13-2005 at 01:55 AM.

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    87
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Add the following to the head portion of the managecart.html page.

    Code:
    <script>
    var called = 1;
    
    function setSubtotal() {
    if (called < 3) {
    document.calc2.loan2.value = TOTotal;
    setTimeout("setSubtotal()","10");
    } else {
    called = 0;
    }
    called++;
    }
    </script>
    Add the following to your <body> tag.

    Code:
    onload="MM_preloadImages('file:///F|/Quote%20Program/program1/images/back_dn.jpg'); setSubtotal();"
    Add the following to the reset tag.

    Code:
    onclick="setSubtotal()"


  •  

    Posting Permissions

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