-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrencyFormatter.html
More file actions
166 lines (144 loc) · 5.08 KB
/
CurrencyFormatter.html
File metadata and controls
166 lines (144 loc) · 5.08 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Currency Formatter</title>
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
/* Global Styles */
body {
background: linear-gradient(to left top, #252a57, #5e4883);
background-size: 100% 32%;
background-repeat: no-repeat;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
font-family: 'Roboto Mono', monospace;
}
.wrapper {
max-width: 600px;
width: 100%;
padding: 20px;
}
.container {
background: rgba(255, 255, 255, 0.1); /* Semi-transparent background */
backdrop-filter: blur(15px); /* Blur effect */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
padding: 40px;
border-radius: 15px;
color: #fff;
border: 1px solid rgba(255, 255, 255, 0.2);
}
input {
height: 40px;
font-size: 16px;
border: none;
border-radius: 8px;
padding: 0 15px;
margin-bottom: 20px;
background-color: rgba(255, 255, 255, 0.3);
color: #fff;
}
button {
background-color: #6637ed;
border: none;
color: white;
height: 40px;
padding: 0 20px;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
}
button:hover {
background-color: #5b2ed2;
}
.result-box {
background: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(10px);
padding: 20px;
margin-top: 30px;
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.result-box p {
margin: 0;
font-size: 18px;
}
.result-box span {
font-weight: bold;
color: #6637ed;
}
/* Responsive Design */
@media (max-width: 576px) {
.container {
padding: 20px;
}
.result-box p {
font-size: 16px;
}
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container">
<div class="mb-3">
<input type="number" id="amount" class="form-control" placeholder="Enter the amount here">
</div>
<div class="d-grid gap-2">
<button id="btn" class="btn btn-primary">Format</button>
<button id="reset-btn" class="btn btn-danger">Reset</button>
</div>
<div id="output" class="result-box">
<p><span>Indian Rupees:</span> <span id="rupees"></span></p>
<p><span>US Dollars:</span> <span id="dollars"></span></p>
<p><span>Japanese Yen:</span> <span id="yen"></span></p>
</div>
</div>
</div>
<!-- Bootstrap 5 JS and Popper -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
<!-- Script for Currency Formatting -->
<script>
let btn = document.getElementById("btn");
let resetBtn = document.getElementById("reset-btn");
let rupees = document.getElementById("rupees");
let dollars = document.getElementById("dollars");
let yen = document.getElementById("yen");
let formatter1 = new Intl.NumberFormat("en-IN", {
style: "currency",
currency: "INR"
});
let formatter2 = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD"
});
let formatter3 = new Intl.NumberFormat("ja-JP", {
style: "currency",
currency: "JPY"
});
// Format the currencies when button is clicked
btn.addEventListener("click", () => {
let amount = document.getElementById("amount").value;
if (amount) {
rupees.innerHTML = formatter1.format(amount);
dollars.innerHTML = formatter2.format(amount);
yen.innerHTML = formatter3.format(amount);
} else {
rupees.innerHTML = dollars.innerHTML = yen.innerHTML = "Please enter a valid amount";
}
});
// Reset the input and results when reset button is clicked
resetBtn.addEventListener("click", () => {
document.getElementById("amount").value = "";
rupees.innerHTML = dollars.innerHTML = yen.innerHTML = "";
});
</script>
</body>
</html>