Problem with unchecking checkbox
Posted: Tue Jul 29, 2003 7:39 pm
Please take a look of this code. I am having problem when I try to uncheck any item. I keeps the cost for unchecked item. Can you please help me to solve this. Thank you.
<html>
<head>
<title></title>
<script type="text/javascript">
<!--
var total = new Number();
function showTotal()
{
var tax = total * (5/100);
var finalTotal = total + tax;
alert("Your total cost is: $" + finalTotal.toFixed(2) + "");
return false;
}
//-->
</script>
</head>
<body>
<form action="">
<p>
<input type="checkbox" onclick="total += 0.59"/> Apple (59 cents each) <br/>
<input type="checkbox" onclick="total += 0.49"/> Orange (49 cents each)<br/>
<input type="checkbox" onclick="total += 0.39"/> Banana (39 cents each)<br/><br/>
<input type="submit" name="submit" value="Submit" onclick="showTotal()"/>
</p>
</form>
</body>
</html>
<html>
<head>
<title></title>
<script type="text/javascript">
<!--
var total = new Number();
function showTotal()
{
var tax = total * (5/100);
var finalTotal = total + tax;
alert("Your total cost is: $" + finalTotal.toFixed(2) + "");
return false;
}
//-->
</script>
</head>
<body>
<form action="">
<p>
<input type="checkbox" onclick="total += 0.59"/> Apple (59 cents each) <br/>
<input type="checkbox" onclick="total += 0.49"/> Orange (49 cents each)<br/>
<input type="checkbox" onclick="total += 0.39"/> Banana (39 cents each)<br/><br/>
<input type="submit" name="submit" value="Submit" onclick="showTotal()"/>
</p>
</form>
</body>
</html>