This is a school assignment i copied from the text book, and it does not work. I am not sure if it is because of a typo in the book, or what.
The page is supposed to take your total food bill, and figure
out the tip as well as split the price for the number of guests. I can not get the Total price nor the Per Person price to work. I have been playing with this for a number of days and still can not figure out why it isnt working. Part of it is working and it looks identical to the part that is not, so it is frustrating….
Any help would be appreciated
Thanks
bandion
[code]
<!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” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”Content-type” content=”text/html;charset=UTF-8″ />
<title>
Tip Calculator
</title>
<script type=”text/javascript”>
/* <![CDATA[ */
function figureTip() {
var bill = document.forms[0].bill.value;
var tipPercent = document.forms[0].tip_percent.value;
var numPeople = document.forms[0].num_people.value;
var tipAmount = Math.round(bill * (“.” + tipPercent));
var total = Math.round(bill * (“1” + “.” + tipPercent));
var totalPerPerson = Math.round(total / numPeople);
document.forms[0].tip_amount.value = tipAmount.toLocaleString();
document.forms[0].total.value = total.toLocaleString();
document.forms[0].total_person.value = totalPerPerson.toLocaleString();
document.forms[0].total_amount.value = total.toLocaleString();
}
/* ]]> */
</script>
</head>
<body>
<script type=”text/javascript”>
<!– hide from incompatible browsers
//stop hiding —>
</script>
<h2>Tip Calculator</h2>
<form action=””>
<table border=”0″>
<tr><td>Bill: </td><td><input type=”text” name=”bill” value=”0″ onchange=”figureTip();” /></td></tr>
<tr><td>Tip %: </td><td><input type=”text” name=”tip_percent” value=”0″ onchange=”figureTip();” />(enter as a whole number)</td></tr>
<tr><td># of People: </td><td><input type=”text” name=”num_people” value=”1″ onchange=”figureTip();” /></td></tr>
<tr><td>Tip amount: </td><td><input type=”text” name=”tip_amount” value=”0″ readonly=”readonly” /></td></tr>
<tr><td>Total: </td><td><input type=”text” name=”total_amount” value=”0″ readonly=”readonly” /></td></tr>
<tr><td>Total per Person:</td><td><input type=”text” name=”total_person” value=”0″ readonly=”readonly” /></td></tr>
</table>
</form>
</body>
</html>