-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
33 lines (25 loc) · 1023 Bytes
/
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
27
28
29
30
31
32
33
var tip = 0.05;
function resetdata(){
tip = 0.05;
document.getElementsByClassName("value")[0].innerHTML = '$0.00';
document.getElementsByClassName("value")[1].innerHTML = '$0.00';
document.getElementById("billvalue").value = 0;
document.getElementsByClassName("button cyanize")[0].value = 0;
document.getElementById("npeople").value = 0;
}
function customtip(){
tip = document.getElementsByClassName("button cyanize")[0].value / 100;
calculatetip();
}
function changetip(newtipvalue){
tip = newtipvalue;
calculatetip();
}
function calculatetip(){
var bill = document.getElementById("billvalue").value;
var npeople = document.getElementById("npeople").value;
var tipamountperson = (bill * tip)/npeople;
var totalperson = (bill/npeople) + tipamountperson;
document.getElementsByClassName("value")[0].innerHTML = '$' + tipamountperson;
document.getElementsByClassName("value")[1].innerHTML = '$' + totalperson;
}