GST Calculator
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
background-color: #ffffff;
}
h1 {
text-align: center;
color: #4CAF50;
}
.input-wrapper {
display: flex;
margin-bottom: 10px;
}
label {
flex: 1;
}
input[type="number"] {
flex: 2;
padding: 10px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 4px;
width: 100%;
}
button:hover {
background-color: #45a049;
}
.result {
margin-top: 20px;
padding: 10px;
background-color: #f2f2f2;
border-radius: 4px;
display: none;
}
.result p {
margin: 0;
color: #333;
}
#gstAmount,
#totalAmount {
font-weight: bold;
color: #333;
}
document.getElementById('calculateButton').addEventListener('click', calculateGST);
function calculateGST() {
const amount = parseFloat(document.getElementById('amount').value);
const gstPercentage = parseFloat(document.getElementById('gstPercentage').value);
if (isNaN(amount) || isNaN(gstPercentage)) {
alert('Please enter valid numeric values.');
return;
}
const gstAmount = (amount * gstPercentage) / 100;
const totalAmount = amount + gstAmount;
showResult(gstAmount, totalAmount);
}
function showResult(gstAmount, totalAmount) {
const resultDiv = document.getElementById('result');
const gstAmountElement = document.getElementById('gstAmount');
const totalAmountElement = document.getElementById('totalAmount');
gstAmountElement.textContent = `GST Amount: ₹ ${gstAmount.toFixed(2)}`;
totalAmountElement.textContent = `Total Amount: ₹ ${totalAmount.toFixed(2)}`;
resultDiv.style.display = 'block';
}
0 Comments