本文介绍了救命 !购物车问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用以下

脚本组合购物车时遇到问题。一切都很好,总计很好,工作完美

除了你选择9.95项目#5 BY ITSELF显示的总数是

$ 9.94!如果你添加其他任何东西,总数是正确的,无论你添加什么,9.95加

。这是这些样品中唯一能够做到这一点的价格。所有其他人都正确显示。如果您将9.95更改为

ANY其他数字,则显示正确。如果你把9.95放在任何其他

的位置(物品编号1而不是5等等它也会做同样的事情)


有什么想法吗?我完全难过了。请帮助

TIA


(这是整个html页面,你可以粘贴它并在浏览器中查看

来查看9.95项目的问题。)


< html>< head>


< script language =" JavaScript">

<! - 隐藏旧浏览器的内容


var费用,Grand_Total;


功能记录( )

{

成本= 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; }


成本=美元(成本);

Grand_Total = parseFloat(成本)

Grand_Total =美元(Grand_Total);


document.orderform.GrandTotal.value =" $" + Grand_Total;

}


功能美元(金额)

{

amount = parseInt(金额* 100);

金额= parseFloat(金额/ 100);

if(((金额)== Math.floor(金额))&&( (金额 - Math.floor

(金额))== 0))

{

金额=金额+" .00"

返还金额;

}

if(((金额* 10) - Math.floor(金额* 10))== 0)

{

金额=金额+" 0" ;;

返还金额;

}

if(((金额* 100) - Math.floor(金额* 100))== 0)

{

金额=金额;

返还金额;

}

返还金额;

}


// - >

< / script>

< / head>

< body>< center>


< form method =" post"名称= QUOT; orderform" action =" mailto:[email protected]"

enctype =" text / plain">

< table bgcolor ="#EFEFEF"边界=" 0" cellspacing =" 0"

cellpadding =" 3">< font face =" verdana"大小= QUOT 1 QUOT; 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">加速拨号上网

1年预付费(119.95美元)

< / p>< p><输入名称= QUOT;项目2"值= QUOT; Item2_chosen" onclick =" tally()"

type =" checkbox">加速拨号上网半年度

预付费($ 75.00)

< / p>< p>< input name =" Item3"值= QUOT; Item3_chosen" onclick =" tally()"

type =" checkbox">加速拨号上网每月结算

($ 14.95)

< / p>< p>< input name =" Item4"值= QUOT; Item4_chosen" onclick =" tally()"

type =" checkbox">定期拨号上网半年度账单

($ 50.00)

< / p>< p>< input name =" Item5"值= QUOT; Item5_chosen" onclick =" tally()"

type =" checkbox">定期拨号上网每月结算

($ 9.95)

< / p>< / td>< td valign =" top">< font面= QUOT;宋体" size =" 2"

color ="#000000">< b>

< / p>< p>< input name =" ;项6"值= QUOT; Item6_chosen" onclick =" tally()"

type =" checkbox">添加3个电子邮件每月结算($ 4.95)

< / p>< p>< input name =" Item7"值= QUOT; Item7_chosen" onclick =" tally()"

type =" checkbox">添加3个电子邮件1年预付费($ 50.00)

< / p>< p>< input name =" Item8"值= QUOT; Item8_chosen" onclick =" tally()"

type =" checkbox"> 10仅电子邮件仅每月结算(7.95)

< / p>< p>< input name =" Item9"值= QUOT; Item9_chosen" onclick =" tally()"

type =" checkbox">通过支票付款的邮件发票($ 1.00)

< br>< br>< font color =" red"> Total Due:< input name =" GrandTotal"

value =" $ 0"大小= QUOT; 8英寸type =" text">< / font>

< / p>< / td>< / tr>< / table>< br>< br>

< center>< input value =" Send Order" type =" submit">< input value ="重置

订单" type =" reset">< / center>

< / form>

< / body>< / html>

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>

推荐答案




这篇关于救命 !购物车问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 21:30