Tax Calculator
const taxCalculator = () => {
const salaryType = document.getElementById(‘salary-type’).value;
const salaryAmount = parseFloat(document.getElementById(‘salary-amount’).value);
const taxRate = 0; // default tax rate
const taxableIncome = salaryAmount;
// apply tax rates based on the selected year and salary amount
if (salaryType === ‘annual’ && taxableIncome > 600000) {
// apply tax rates for annual salary
} else if (salaryType === ‘monthly’ && taxableIncome > 50000) {
// apply tax rates for monthly salary
}
const taxLiability = taxableIncome * taxRate;
document.getElementById(‘tax-result’).innerHTML = `Your tax liability is: Rs. ${taxLiability.toFixed(2)}`;
};
document.getElementById(‘check-tax’).addEventListener(‘click’, taxCalculator);
HTML
<div id=”tax-calculator”> <select id=”salary-type”> <option value=”monthly”>Monthly Salary</option> <option value=”annual”>Annual Salary</option> </select> <input type=”number” id=”salary-amount” placeholder=”Enter salary amount”> <button id=”check-tax”>Check Tax</button> <div id=”tax-result”></div> </div>const taxCalculator = () => {
const salaryType = document.getElementById('salary-type').value;
const salaryAmount = parseFloat(document.getElementById('salary-amount').value);
const taxRate = 0; // default tax rate
const taxableIncome = salaryAmount;
// apply tax rates based on the selected year and salary amount
if (salaryType === 'annual' && taxableIncome > 600000) {
// apply tax rates for annual salary
} else if (salaryType === 'monthly' && taxableIncome > 50000) {
// apply tax rates for monthly salary
}
const taxLiability = taxableIncome * taxRate;
document.getElementById('tax-result').innerHTML = `Your tax liability is: Rs. ${taxLiability.toFixed(2)}`;
};
document.getElementById('check-tax').addEventListener('click', taxCalculator);