0

Hey, i'm seeming to have a problem with the code below, in my calculations the values don't seem to add, it just adds the 1.50 to 25 like 25.0015 please if theres anyone who could help with this.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Calculation</title>

<script type = "text/javascript" >
/* <![CDATA[ */
function CalcShopping(promt) {
	parseFloat(promt)
	if (promt <= 25) {
	var calcLess = promt + 1.50;
	window.alert("Your total charge for handling and shipping plus your item is $" +calcLess+ "");
	}
    else if (promt > 25)
		var calcMore = (promt * 10 / 100) + promt;
		window.alert("Your total charge for handling and shipping plus your item is $" +calcMore+ "");
	
}
/* ]]> */
</script>
</head>

<body>
<script type= "text/javascript" >
/* <![CDATA[ */
var promtBox = window.prompt("Please enter your item charge", "Here");
parseFloat(promtBox)
CalcShopping(promtBox);
/* ]]> */
</script>
</body>
</html>

Thanks

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Doky123
0

Try this...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Shopping Calculation</title>

<script type = "text/javascript" >
/* <![CDATA[ */
function CalcShopping(promt) {
	promt = parseFloat(promt)
	if (promt <= 25) {
	var calcLess = promt + 1.50;
	window.alert("Your total charge for handling and shipping plus your item is $" +calcLess+ "");
	}
    else if (promt > 25)
    {
		var calcMore = (promt * 10 / 100) + promt;
		window.alert("Your total charge for handling and shipping plus your item is $" +calcMore+ "");
	}	
	
}
/* ]]> */
</script>
</head>

<body>
<script type= "text/javascript" >
/* <![CDATA[ */
var promtBox = window.prompt("Please enter your item charge", "Here");
CalcShopping(promtBox);
/* ]]> */
</script>
</body>
</html>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.