GST calculator html code -free html code - html code with java script - GST Calculator html code
Here is a code for GST calculator online
<html>
<head>
<title>GST Calculator</title>
<style>
.container {
width: 300px;
margin: 0 auto;
}
.input-field {
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h2>GST Calculator</h2>
<div class="input-field">
<label for="amount">Amount:</label>
<input id="amount" min="0" step="0.01" type="number" />
</div>
<div class="input-field">
<label for="gstRate">GST Rate (%):</label>
<input id="gstRate" min="0" step="0.01" type="number" />
</div>
<div class="input-field">
<button onclick="calculateGST()">Calculate</button>
</div>
<div class="input-field">
<label for="total">Total Amount (including GST):</label>
<input id="total" readonly="" type="text" />
</div>
<div class="input-field">
<label for="gstAmount">GST Amount:</label>
<input id="gstAmount" readonly="" type="text" />
</div>
</div>
<script>
function calculateGST() {
var amount = document.getElementById("amount").value;
var gstRate = document.getElementById("gstRate").value;
// Perform validation
if (amount === "" || gstRate === "") {
alert("Please enter an amount and GST rate.");
return;
}
var gstAmount = (amount * (gstRate / 100)).toFixed(2);
var total = (parseFloat(amount) + parseFloat(gstAmount)).toFixed(2);
document.getElementById("total").value = total;
document.getElementById("gstAmount").value = gstAmount;
}
</script>
</body>
Comments
Post a Comment