P
Phil McKraken
I am having a problem putting together a shopping cart with the below
script. Everything displays fine, adds totals fine, and works perfect
EXCEPT if you choose the 9.95 item #5 BY ITSELF the total displayed is
$9.94 ! If you add ANYTHING else the total is correct, 9.95 plus
whatever you add. That is the only price in these samples that is
doing that. All the others display properly. If you change the 9.95 to
ANY other number it displays correct. If you put 9.95 in any other
position (Item number 1 instead of 5 etc. it does the same thing)
Any ideas ? I am completely stumped. Please Help
TIA
(This is the entire html page you can paste it and view in a browser
to see the problem with the 9.95 item.)
<html><head>
<script language="JavaScript">
<!-- hide contents from old browsers
var Cost, Grand_Total;
function tally()
{
Cost = 0;
if (document.orderform.Item1.checked) { Cost = Cost + 119.95;
}
if (document.orderform.Item2.checked) { Cost = Cost + 75.00; }
if (document.orderform.Item3.checked) { Cost = Cost + 14.95; }
if (document.orderform.Item4.checked) { Cost = Cost + 50.00; }
if (document.orderform.Item5.checked) { Cost = Cost + 9.95; }
if (document.orderform.Item6.checked) { Cost = Cost + 4.95; }
if (document.orderform.Item7.checked) { Cost = Cost + 50.00; }
if (document.orderform.Item8.checked) { Cost = Cost + 7.95; }
if (document.orderform.Item9.checked) { Cost = Cost + 1.00; }
Cost = dollar(Cost);
Grand_Total = parseFloat(Cost)
Grand_Total = dollar(Grand_Total);
document.orderform.GrandTotal.value = "$" + Grand_Total;
}
function dollar (amount)
{
amount = parseInt(amount * 100);
amount = parseFloat(amount/100);
if (((amount) == Math.floor(amount)) && ((amount - Math.floor
(amount)) == 0))
{
amount = amount + ".00"
return amount;
}
if ( ((amount * 10) - Math.floor(amount * 10)) == 0)
{
amount = amount + "0";
return amount;
}
if ( ((amount * 100) - Math.floor(amount * 100)) == 0)
{
amount = amount;
return amount;
}
return amount;
}
//-->
</script>
</head>
<body><center>
<form method="post" name="orderform" action="mailto:[email protected]"
enctype="text/plain">
<table bgcolor="#EFEFEF" border="0" cellspacing="0"
cellpadding="3"><font face="verdana" size="1" color="#000000"><b>
<tr><td valign="top"><font face="verdana" size="2"
color="#000000"><b>
<p><input name="Item1" value="AcceleratedHighSpeedAnnual"
onclick="tally()" type="checkbox">Accelerated Dial-Up Internet Access
1 Year Pre-Pay ($119.95)
</p><p><input name="Item2" value="Item2_chosen" onclick="tally()"
type="checkbox"> Accelerated Dial Up Internet Access Semi-Annual
Pre-Pay ($75.00)
</p><p><input name="Item3" value="Item3_chosen" onclick="tally()"
type="checkbox"> Accelerated Dial Up Internet Access Monthly Billing
($14.95)
</p><p><input name="Item4" value="Item4_chosen" onclick="tally()"
type="checkbox"> Regular Dial Up Internet Access Semi-Annual Billing
($50.00)
</p><p><input name="Item5" value="Item5_chosen" onclick="tally()"
type="checkbox"> Regular Dial Up Internet Access Monthly Billing
($9.95)
</p></td><td valign="top"><font face="verdana" size="2"
color="#000000"><b>
</p><p><input name="Item6" value="Item6_chosen" onclick="tally()"
type="checkbox"> Add 3 Email Monthly Billing ($4.95)
</p><p><input name="Item7" value="Item7_chosen" onclick="tally()"
type="checkbox"> Add 3 Email 1 Year Pre-Pay ($50.00)
</p><p><input name="Item8" value="Item8_chosen" onclick="tally()"
type="checkbox"> 10 Email Only Monthly Billing Only (7.95)
</p><p><input name="Item9" value="Item9_chosen" onclick="tally()"
type="checkbox"> Mail Invoice for Payment by Check ($1.00)
<br><br><font color="red">Total Due: <input name="GrandTotal"
value="$0" size="8" type="text"></font>
</p></td></tr></table><br><br>
<center><input value="Send Order" type="submit"><input value="Reset
Order" type="reset"></center>
</form>
</body></html>
script. Everything displays fine, adds totals fine, and works perfect
EXCEPT if you choose the 9.95 item #5 BY ITSELF the total displayed is
$9.94 ! If you add ANYTHING else the total is correct, 9.95 plus
whatever you add. That is the only price in these samples that is
doing that. All the others display properly. If you change the 9.95 to
ANY other number it displays correct. If you put 9.95 in any other
position (Item number 1 instead of 5 etc. it does the same thing)
Any ideas ? I am completely stumped. Please Help
TIA
(This is the entire html page you can paste it and view in a browser
to see the problem with the 9.95 item.)
<html><head>
<script language="JavaScript">
<!-- hide contents from old browsers
var Cost, Grand_Total;
function tally()
{
Cost = 0;
if (document.orderform.Item1.checked) { Cost = Cost + 119.95;
}
if (document.orderform.Item2.checked) { Cost = Cost + 75.00; }
if (document.orderform.Item3.checked) { Cost = Cost + 14.95; }
if (document.orderform.Item4.checked) { Cost = Cost + 50.00; }
if (document.orderform.Item5.checked) { Cost = Cost + 9.95; }
if (document.orderform.Item6.checked) { Cost = Cost + 4.95; }
if (document.orderform.Item7.checked) { Cost = Cost + 50.00; }
if (document.orderform.Item8.checked) { Cost = Cost + 7.95; }
if (document.orderform.Item9.checked) { Cost = Cost + 1.00; }
Cost = dollar(Cost);
Grand_Total = parseFloat(Cost)
Grand_Total = dollar(Grand_Total);
document.orderform.GrandTotal.value = "$" + Grand_Total;
}
function dollar (amount)
{
amount = parseInt(amount * 100);
amount = parseFloat(amount/100);
if (((amount) == Math.floor(amount)) && ((amount - Math.floor
(amount)) == 0))
{
amount = amount + ".00"
return amount;
}
if ( ((amount * 10) - Math.floor(amount * 10)) == 0)
{
amount = amount + "0";
return amount;
}
if ( ((amount * 100) - Math.floor(amount * 100)) == 0)
{
amount = amount;
return amount;
}
return amount;
}
//-->
</script>
</head>
<body><center>
<form method="post" name="orderform" action="mailto:[email protected]"
enctype="text/plain">
<table bgcolor="#EFEFEF" border="0" cellspacing="0"
cellpadding="3"><font face="verdana" size="1" color="#000000"><b>
<tr><td valign="top"><font face="verdana" size="2"
color="#000000"><b>
<p><input name="Item1" value="AcceleratedHighSpeedAnnual"
onclick="tally()" type="checkbox">Accelerated Dial-Up Internet Access
1 Year Pre-Pay ($119.95)
</p><p><input name="Item2" value="Item2_chosen" onclick="tally()"
type="checkbox"> Accelerated Dial Up Internet Access Semi-Annual
Pre-Pay ($75.00)
</p><p><input name="Item3" value="Item3_chosen" onclick="tally()"
type="checkbox"> Accelerated Dial Up Internet Access Monthly Billing
($14.95)
</p><p><input name="Item4" value="Item4_chosen" onclick="tally()"
type="checkbox"> Regular Dial Up Internet Access Semi-Annual Billing
($50.00)
</p><p><input name="Item5" value="Item5_chosen" onclick="tally()"
type="checkbox"> Regular Dial Up Internet Access Monthly Billing
($9.95)
</p></td><td valign="top"><font face="verdana" size="2"
color="#000000"><b>
</p><p><input name="Item6" value="Item6_chosen" onclick="tally()"
type="checkbox"> Add 3 Email Monthly Billing ($4.95)
</p><p><input name="Item7" value="Item7_chosen" onclick="tally()"
type="checkbox"> Add 3 Email 1 Year Pre-Pay ($50.00)
</p><p><input name="Item8" value="Item8_chosen" onclick="tally()"
type="checkbox"> 10 Email Only Monthly Billing Only (7.95)
</p><p><input name="Item9" value="Item9_chosen" onclick="tally()"
type="checkbox"> Mail Invoice for Payment by Check ($1.00)
<br><br><font color="red">Total Due: <input name="GrandTotal"
value="$0" size="8" type="text"></font>
</p></td></tr></table><br><br>
<center><input value="Send Order" type="submit"><input value="Reset
Order" type="reset"></center>
</form>
</body></html>