GST Calculator

.gst-calculator { max-width: 500px; margin: 40px auto; padding: 25px; background: #fdfdfd; border-radius: 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08); font-family: 'Segoe UI', sans-serif; } .gst-calculator h2 { text-align: center; margin-bottom: 20px; color: #333; font-size: 22px; } .gst-calculator label { display: block; margin-bottom: 6px; font-weight: 600; color: #444; } .gst-calculator input { width: 100%; padding: 12px; font-size: 16px; border: 1px solid #ccc; border-radius: 10px; margin-bottom: 20px; box-sizing: border-box; } .gst-calculator button { width: 100%; padding: 14px; background-color: #4CAF50; color: #fff; border: none; font-weight: bold; font-size: 16px; border-radius: 10px; cursor: pointer; transition: background 0.3s ease; } .gst-calculator button:hover { background-color: #43a047; } .gst-calculator #gstResult { text-align: center; margin-top: 20px; font-size: 18px; color: #222; } @media (max-width: 600px) { .gst-calculator { padding: 20px; } .gst-calculator h2 { font-size: 20px; } .gst-calculator input, .gst-calculator button { font-size: 15px; } }

💰 GST Calculator

function calculateGST() { const amount = parseFloat(document.getElementById("amount").value); const gstRate = parseFloat(document.getElementById("gstPercent").value); const resultDiv = document.getElementById("gstResult"); if (isNaN(amount) || amount <= 0) { resultDiv.innerHTML = "🚫 Please enter a valid amount."; return; } if (isNaN(gstRate) || gstRate < 0) { resultDiv.innerHTML = "🚫 Please enter a valid GST percentage."; return; } const gstAmount = (amount * gstRate) / 100; const totalAmount = amount + gstAmount; resultDiv.innerHTML = `

🧾 Original Amount: ₹${amount.toFixed(2)}

➕ GST (${gstRate}%): ₹${gstAmount.toFixed(2)}

💰 Total (Post-GST): ₹${totalAmount.toFixed(2)}

`; }

About the Author

You may also like these