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

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>

Great it works thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.