-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemp.html
More file actions
32 lines (30 loc) · 839 Bytes
/
Copy pathemp.html
File metadata and controls
32 lines (30 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<head>
<title>Tip Calculator</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<header>
<h1>Tip Calculator</h1>
</header>
<form action="javascript:void(calc())">
Amount: $<input id="bill" type="text">
<br>
<input type="submit" value="Calculate">
<br>
Tip: <span id="tip"></span>
<br>
Total: <span id="total"></span>
</form>
</div>
<script>
function calc() {
var bill = Number(document.getElementById('bill').value);
var tip = bill * .15;
var total_bill = bill + tip;
document.getElementById("tip").innerHTML= "$"+Number(tip).toFixed(2);
document.getElementById("total").innerHTML= "$"+Number(total_bill).toFixed(2);
}
</script>
</body>