...

View Full Version : ?'s About JavaScript cart



Rave_fxz
10-13-2005, 01:26 AM
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:

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



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;
}

pccode
10-13-2005, 10:32 AM
Add the following to the head portion of the managecart.html page.



<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.



onload="MM_preloadImages('file:///F|/Quote%20Program/program1/images/back_dn.jpg'); setSubtotal();"


Add the following to the reset tag.



onclick="setSubtotal()"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum