html
html
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
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div id="wrapper">
<h1>Calculate Price App</h1>
<img src="https://i.ibb.co/JC29FGD/kissclipart-calculator-money-icon-clipart-computer-icons-money-55ed82941d167397.png"/>
<form id="myForm" action="#" onSubmit="return false;">
<label>Enter Price:</label>
<br />
<input id="price" type="number" value=""/>
<br />
<label>Enter Tip:</label>
<br />
<input id="tip" type="number" value=""/>
<button onclick="total()">Submit</button>
</form>
<br />
<p>Total Price: <span id="total"></span></p>
<p>Total Tip: <span id="total-tip"></span></p>
<p>Total Amount: <span id="total-a"></span></p>
<p id="list"></p>
<p>Built with ♥ By Talal Emran, 2021</p>
</div>
</body>
Enter to Rename, Shift+Enter to Preview
css
css
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
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');
body {
font-family: 'Titillium Web', sans-serif;
background-color: #073B4C;
color: #FFFFFF;
}
h1 {
font-size: 22px;
color: #FFD166;
text-align: center;
}
img {
width: 40%;
display: block;
margin-left: auto;
margin-right: auto;
}
#wrapper {
width: 90%;
max-width: 600px;
margin: 80px auto;
background-color: #118AB2;
padding: 10px;
box-shadow: 2px 2px 5px #000000;
Enter to Rename, Shift+Enter to Preview
js
js
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
let items = [];
let tips = [];
function total() {
pricevalue = document.getElementById('price').value;
tipvalue = document.getElementById('tip').value;
if (pricevalue == "") {
alert ("Please, enter price!");
return false;
}
if (tipvalue == "") {
alert ("Please, enter tip!");
return false;
}
items.push(parseInt(pricevalue));
tips.push(parseInt(tipvalue));
let sum = 0;
let tipSum = 0;
let openList = "<ul class='striped-list' >";
let listItem = "";
let tipItem = "";
let closeList = "</ul>"
for (let i = 0; i < items.length; i++) {
sum += items[i];
listItem += "<li>" + "Price: $" + items[i] + ", Tip: $" + tips[i] + "</li>";
}
for (let i = 0; i < tips.length; i++) {
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run