GST Calculator
/* General Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #ff7e5f, #feb47b);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.calculator {
background-color: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}
label {
display: block;
margin: 10px 0 5px;
color: #333;
font-weight: 500;
}
input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
}
button {
width: 100%;
padding: 12px;
background-color: #ff7e5f;
color: white;
font-size: 18px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
}
button:hover {
background-color: #feb47b;
}
.result {
margin-top: 20px;
text-align: center;
}
.result p {
font-size: 18px;
font-weight: bold;
color: #333;
}
@media screen and (max-width: 600px) {
.calculator {
padding: 20px;
}
h1 {
font-size: 22px;
}
input, button {
font-size: 14px;
padding: 8px;
}
}
function calculateGST() {
// Get the values from the input fields
let price = parseFloat(document.getElementById("price").value);
let gstRate = parseFloat(document.getElementById("gstRate").value);
// Check if values are valid numbers
if (isNaN(price) || isNaN(gstRate) || price <= 0 || gstRate < 0) {
alert("Please enter valid values for price and GST rate.");
return;
}
// Calculate GST amount and total price
let gstAmount = (price * gstRate) / 100;
let totalPrice = price + gstAmount;
// Display the results
document.getElementById("gstAmount").textContent = "GST Amount: ₹" + gstAmount.toFixed(2);
document.getElementById("totalPrice").textContent = "Total Price (Including GST): ₹" + totalPrice.toFixed(2);
}