-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
71 lines (61 loc) · 1.98 KB
/
app.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function btnclick() {
let unitid = document.getElementById("unit").value;
let perunit = document.getElementById("perunit").value;
let infobox = document.getElementById("infobox");
infobox.classList.add("hide");
let total = Number(unitid) * Number(perunit);
function bill() {
let nameid = document.getElementById("name").value;
if (nameid == "") {
alert("Please Enter Your Name");
location.reload();
return;
}
// createElement
let box = document.getElementById("box");
let boxdata = document.createElement("div");
let latecharge = document.getElementById("penalty").value;
boxdata.setAttribute("class", "info-box-1");
let reloadbtn = document.createElement("button");
reloadbtn.setAttribute('class','bill');
reloadbtn.setAttribute('onclick','reloadbtn()');
reloadbtn.innerHTML = 'ReGenerate Bill';
let latetotal = total + Number(latecharge);
// month
let month = new Date();
let monthname = month.getMonth();
let montharray = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
let monthget = montharray[monthname];
boxdata.innerHTML = `
<p><b>Customer Name : </b><i> ${nameid}</i>.</p>
<p><b>Month of : </b><i>${monthget}</i>.</p>
<p><b>Number Of Units : </b><i>${unitid}</i>.</p>
<p><b>Net Amount Payable (within Due Date): </b> <br> <i>${total.toFixed(
2
)}-Pkr</i>.</p>
<p><b>Per unit price : </b><i>${perunit}<b>,</b>Pkr</i>.</p>
<p><b>Late payment penalty : </b><i>${latecharge}<b>,</b>Pkr</i>.</p>
<p><b>Gross Amount Payable (after Due Date):</b> <br> <i>${latetotal}<b>,</b>Pkr</i>.</p>`;
boxdata.appendChild(reloadbtn);
box.appendChild(boxdata);
reloadbtn();
}
bill();
}
function reloadbtn() {
location.reload();
}
// btnclick();