-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamic_bill.html
120 lines (94 loc) · 3.67 KB
/
dynamic_bill.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.min.js" integrity="sha384-+sLIOodYLS7CIrQpBjl+C7nPvqq+FbNUBDunl/OZv93DB7Ln/533i8e/mZXLi/P+" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<h1 class="text-center text-primary font-weight-bold mt-5 mb-5 text-uppercase">Billing Demo</h1>
</div>
</div>
<div class="row">
<div class="col-4 text-center bg-dark p-3">
<input type="text" id="name" placeholder="Enter product Name ...." class="form-control mt-3" name=""> <!-- form control is use take full screen or of full width -->
<input type="text" id="rate" placeholder="Enter product Rate ...." class="form-control mt-3" name="">
<input type="text" id="qnt" placeholder="Enter product Qnt ...." class="form-control mt-3" name="">
<input type="text" id="dis" placeholder="Enter product Dis(%) ...." class="form-control mt-3" name="">
<input type="text" id="tot" placeholder="Enter product Total ...." class="form-control mt-3" name="" readonly>
<button class="btn btn-primary btn-lg mt-4 " onclick="addrow()">Add product</button>
</div>
<div class="col-8">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Name</th>
<th>Rate</th>
<th>Qnt</th>
<th>Dis</th>
<th>Total</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
<tfoot class="bg-warning p-2">
<tr>
<td colspan="4">
<h3 class="text-white text-right">Total = </h3>
</td>
<td id="total"></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<script type="text/javascript" src="cdn/jquery-3.7.1.js"></script>
<script type="text/javascript" src="cdn/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="cdn/jquery-3.7.1.slim.js"></script>
<script type="text/javascript" src="cdn/jquery-3.7.1.slim.min.js"></script>
<!-- Ajax cdn W3 school -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#rate, #qnt , #dis').keyup(function(){
var rate=$('#rate').val();
var qnt=$('#qnt').val();
var dis=$('#dis').val();
var to=Number(rate)*Number(qnt);
var disamt=Number(to)*Number(dis)/100;
var tot=Number(to)-Number(disamt);
$('#tot').val(tot);
})
})
function addrow()
{
var name=$('#name').val();
var rate=$('#rate').val();
var qnt=$('#qnt').val();
var dis=$('#dis').val();
var tot=$('#tot').val();
var data="<tr><td>"+name+"</td><td>"+rate+"</td><td>"+qnt+"</td><td>"+dis+"</td><td class='total'>"+tot+"</td></tr>";
$('#tbody').append(data);
total();
}
function total(){
var a=document.getElementsByClassName('total');
var to=0;
for(var i=0;i<a.length;i++)
{
to+=Number(a[i].innerText)
}
$('#total').text(to+"Rs");
}
</script>
</body>
</html>