-
Notifications
You must be signed in to change notification settings - Fork 1
/
Invocegenerator.html
184 lines (176 loc) · 5.14 KB
/
Invocegenerator.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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Code By Sarfaraz's Coding Club -->
<!-- Subscribe on YouTube (https://youtube.com/@sarfaraz'scodingclub) -->
<style>*{
margin: 0px;
padding: 0px;
}
.container{
width: 400px;
height: 600px;
background-color: dodgerblue;
border: none;
border-radius: 10px;
margin: 150px auto;
padding: 10px;
}
.container h3{
text-transform: uppercase;
color: white;
font-size: 25px;
text-align: center;
font-family: verdana;
}
.container input{
margin: 2px;
margin-top: 20px;
height: 30px;
color: black;
border: none;
border-radius: 3px;
padding: 2px;
}
#ItemName{
width: 48%;
}
#ItemPrice{
width: 22%;
}
#quantity{
width: 22%;
}
#mainbutton{
margin-left: 10px;
margin-top: 10px;
width: 90%;
height: 30px;
padding: 2px;
border: none;
border-radius: 10px;
background-color: white;
color: dodgerblue;
font-size: 18px;
text-align: center;
font-weight: bold;
}
#mainbutton:hover{
background-color: transparent;
color: white;
border: 2px solid white;
}
/* Invoice Display Style */
.container h2{
margin-top: 20px;
margin-bottom: 20px;
color: white;
text-transform: uppercase;
text-align: center;
font-size: 18px;
font-family: verdana;
}
#invoiceTable{
width: 98%;
margin: 2px;
padding: 2px;
color: white;
border: 1px solid white;
background-color: rgb(6, 67, 128);
border-radius: 5px;
}
.container h6{
margin-top: 20px;
color: white;
font-size: 18px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
text-transform: uppercase;
text-align: center;
}
#totalAmount{
background-color: rgb(5, 45, 85);
color: white;
padding: 2px;
margin: 2px;
border-radius: 2px;
}
#del{
width: 80px;
height: 20px;
color: white;
background-color: red;
padding: 2px;
text-align: center;
margin: 2px;
}</style>
<title>Invoice Generator</title>
</head>
<body>
<div class="container">
<!-- Invoice Input -->
<h3>Invoice Generator</h3>
<form id="invoiceForm">
<input type="text" id="ItemName" placeholder="Enter Item...">
<input type="number" id="ItemPrice" placeholder="Enter Price...">
<input type="number" id="quantity" placeholder="Qty">
<button type="button" onclick="addItem()" id="mainbutton">Add Item</button>
</form>
<!-- Invoice Display Section -->
<h2>Invoice</h2>
<table id="invoiceTable">
<tr>
<th>Item Name</th>
<th>Price</th>
<th>Qty</th>
<th>Total</th>
<th>Action</th>
</tr>
</table>
<h6>Total Amount <span id="totalAmount">0</span></h6>
</div>
</body>
<script>
function addItem(){
var itemName = document.getElementById('ItemName').value;
var itemPrice = document.getElementById('ItemPrice').value;
var qty = document.getElementById('quantity').value;
var total = itemPrice * qty;
var table = document.getElementById('invoiceTable');
var row = table.insertRow(-1);
var itemNameCell = row.insertCell(0);
var priceCell = row.insertCell(1);
var quantityCell = row.insertCell(2);
var totalCell = row.insertCell(3);
var actionCell = row.insertCell(4);
itemNameCell.innerHTML = itemName;
priceCell.innerHTML = itemPrice;
quantityCell.innerHTML = qty;
totalCell.innerHTML = total;
actionCell.innerHTML = "<button id='del' onclick='deleteItem(this.parentNode.parentNode)'> Delete </button> ";
var itemName = document.getElementById('ItemName').value = "";
var itemPrice = document.getElementById('ItemPrice').value = "";
var qty = document.getElementById('quantity').value = "";
updateTotalAmount();
}
function deleteItem(row){
var table = document.getElementById('invoiceTable');
var rowIndex = row.rowIndex;
table.deleteRow(rowIndex);
updateTotalAmount();
}
function updateTotalAmount(){
var table = document.getElementById('invoiceTable');
var rowCount = table.rows.length;
var totalAmount = 0;
for (var i = 1; i < rowCount; i++){
var row = table.rows[i];
var totalCell = row.cells[3];
totalAmount += parseFloat(totalCell.innerHTML);
}
document.getElementById("totalAmount").innerHTML = totalAmount;
}
</script>
</html>