I am creating a simple page that has to do with room rates. It shows if you stay this night to this night it’s this etc….but I need it to calculate the total cost. Example..If you stay 7 nights, your cost per night $105.00, but it also need to show the total cost is…so the price per night * the number of nights. I am missing something in my process and can’t quite figure it out. Here is what I have.
<!DOCTYPE HTML>
<html>
<head>
<title>roomRates</title>
<script>
function calcPrice() {
var night=document.getElementById(“roomPrice”).value;
var price=0;
if (night <= 3) {
price = 125;
} else if (night < 8) {
price = 105;
} else if (night < 11) {
price = 95;
} else {
price = 85;
}
document.getElementById(“outPrice”).innerHTML = “The price per night is: $” + price.toFixed(2) +”.”;
document.getElementById(“outCost”).innerHTML = “The total cost is: $” + toalCost.toFixed(2) +”.”;
}
</script>
</head>
<body>
<h1>roomRate<h1>
<p>
Number of Nights: <input id=”roomPrice” type=”number” min=”1″ max=”15″ size=”8″>
</p>
<button type=”button” onClick=”calcPrice()”>Submit</button>
<br/>
<p id= “outPrice”></p>
<p id= “outCost”></p>
</body>
</html>