-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pop-up-tkBonton.html
159 lines (150 loc) · 4.12 KB
/
Pop-up-tkBonton.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Money Contribution Calculator</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f4f4f4;
}
.container {
text-align: center;
}
input {
width: 80%;
padding: 10px;
margin: 10px 0;
font-size: 16px;
box-sizing: border-box;
}
button {
background-color: #4caf50;
color: #fff;
padding: 12px 24px;
font-size: 16px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease-in-out;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
font-size: 18px;
color: #333;
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.popup {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
justify-content: center;
align-items: center;
}
.popup-content {
background-color: #fff;
padding: 20px;
border-radius: 8px;
text-align: center;
animation: zoomIn 0.5s ease-in-out;
}
@keyframes zoomIn {
from {
transform: scale(0);
}
to {
transform: scale(1);
}
}
.popup h2 {
color: #4caf50;
}
.popup button {
background-color: #4caf50;
color: #fff;
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease-in-out;
}
.popup button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<input type="number" id="totalAmount" placeholder="Enter the total amount" required>
<br>
<input type="number" id="wifePercentage" placeholder="Enter wife's percentage" required>
<br>
<input type="number" id="son1Percentage" placeholder="Enter son 1's percentage" required>
<br>
<input type="number" id="son2Percentage" placeholder="Enter son 2's percentage" required>
<br>
<button onclick="calculateContribution()">Calculate Contribution</button>
<div id="result"></div>
</div>
<div class="popup" id="congratulationsPopup">
<div class="popup-content">
<h2>Congratulations!</h2>
<p>Wow, you've successfully calculated contributions!</p>
<button onclick="closePopup()">Close</button>
</div>
</div>
<script>
function calculateContribution() {
// Retrieve input values
const totalAmount = parseFloat(document.getElementById("totalAmount").value) || 0;
const wifePercentage = parseFloat(document.getElementById("wifePercentage").value) || 0;
const son1Percentage = parseFloat(document.getElementById("son1Percentage").value) || 0;
const son2Percentage = parseFloat(document.getElementById("son2Percentage").value) || 0;
// Calculate contributions
const wifeContribution = (wifePercentage / 100) * totalAmount;
const son1Contribution = (son1Percentage / 100) * totalAmount;
const son2Contribution = (son2Percentage / 100) * totalAmount;
// Display result
const resultDiv = document.getElementById("result");
resultDiv.innerHTML = `
<h2>Contributions</h2>
<strong>Wife's Contribution:</strong> $${wifeContribution.toFixed(2)}<br>
<strong>Son 1's Contribution:</strong> $${son1Contribution.toFixed(2)}<br>
<strong>Son 2's Contribution:</strong> $${son2Contribution.toFixed(2)}
`;
// Show congratulations popup
showPopup();
}
function showPopup() {
const popup = document.getElementById("congratulationsPopup");
popup.style.display = "flex";
}
function closePopup() {
const popup = document.getElementById("congratulationsPopup");
popup.style.display = "none";
}
</script>
</body>
</html>