This code doesn\'t work. It is supposed to be a program that shows on a browser
ID: 3771410 • Letter: T
Question
This code doesn't work.
It is supposed to be a program that shows on a browser (html) written in Javascript . Please do not use Java libraries
<!DOCTYPE html>
<body>
<script>
function calc()
{
var foodTotal =
parseInt (document.getElementById ("foodTotal") .value, 10);
// calculating tax
var tax = foodTotal*.07;
//calculating subtotal
var subtotal=foodTotal+tax;
//calculating tip
var tip=subtotal+.15;
//calculating grandTotal
var grandTotal=subtotal+tip;
document.write("The food total is $ ",foodTotal);
document.write("The tax is $ ",tax);
document.write("The tip is $ ",tip);
document.write("The total with tax and tip is $ ", grandTotal);
}
</script>
<form action="" method="POST">
<br/>
<p> Enter food total</p>
<input type="text" id="foodTotal" value="0" size="5" />
</form>
</body>
</html>
( No Java libraries!!!!!)
Explanation / Answer
<!DOCTYPE html>
<body>
<script>
function calc()
{
var foodTotal =
parseInt (document.getElementById ("foodTotal")
.value, 10);
// calculating tax
var tax = foodTotal*.07;
//calculating subtotal
var subtotal=foodTotal+tax;
//calculating tip
var tip=subtotal+.15;
//calculating grandTotal
var grandTotal=subtotal+tip;
document.write("The food total is $ ",foodTotal);
document.write("The tax is $ ",tax);
document.write("The tip is $ ",tip);
document.write("The total with tax and tip is $ ",
grandTotal);
}
</script>
<form action="" method="POST">
<br/>
<p> Enter food total</p>
<input type="text" id="foodTotal" value="0" size="5" />
</form>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.