-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
26 lines (19 loc) · 1.01 KB
/
script.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
function tipCalculator(){
var oops;
if(document.getElementById('billAmount').value===" " || document.getElementById('Service').value==0){
window.alert('Please enter some values to get this baby up and running');
return;
}
if(document.getElementById('numPeople').value=="" || document.getElementById('numPeople').value==1){
document.getElementById('each').style.display="none";
oops=document.getElementById('billAmount').value*document.getElementById('Service').value;
}
else{
document.getElementById('each').style.display="block";
oops=document.getElementById('billAmount').value*document.getElementById('Service').value/document.getElementById('numPeople').value;
}
document.getElementById('totalTip').style.display="block";
document.getElementById('tip').innerHTML=oops;
}
document.getElementById('totalTip').style.display="none";
document.getElementById('Calculate').onclick=function() {tipCalculator();};