-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscount.html
100 lines (85 loc) · 3.75 KB
/
discount.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Discount Calculator</title>
<link rel=" stylesheet " href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css " integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4 " crossorigin="anonymous ">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<link rel="stylesheet " href="/css/home.css">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col">
<h1 class="weight padding-calculate">Calculate Discount</h1>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="padding-calculate">
<form name="discountForm">
<div class="form-group">
<label for="email"> Enter the Discount in % </label>
<input type="number" onkeydown="javascript: return event.keyCode == 69 ? false : true" class="form-control" id="discount" min="0" max="100" required />
</div>
<div class="form-group">
<label for="pwd"> Enter the Total amount</label>
<input type="number" onkeydown="javascript: return event.keyCode == 69 ? false : true" class="form-control" id="total" required />
</div>
<button type="button" class="btn btn-primary" onclick="myFunction()" data-toggle="modal" data-target="#discountModal">Submit</button>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="discountModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">The discounted amount is</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p id="demo"></p>
<h5>You need to pay</h5>
<p id="amount"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function myFunction() {
var x = document.getElementById('discount').value;
var y = document.getElementById('total').value;
var d, m, a, pay;
if (x > 100 || x < 0 || x == "") {
document.getElementById('discountModal').disabled;
alert("Please input correct % amount");
return false;
}
if (y == "") {
document.getElementById('discountModal'.disabled);
alert("Idiot Enter something to work");
return flase;
}
d = x / 100; //converting it to the point value;
m = y * d;
a = y - m;
document.getElementById('demo').innerHTML = m;
document.getElementById('amount').innerHTML = a;
}
</script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
</body>
</html>
</html>