Pages

Wednesday, 27 November 2024

Sales Tax Calculator Tool

Sales Tax Calculator

Sales Tax Calculator

body { font-family: 'Arial', sans-serif; background-color: #f4f7f6; color: #333; } .container { margin-top: 50px; } .card { background-color: #ffffff; border-radius: 8px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); } .card-body { padding: 20px; } h3, h5 { font-weight: bold; } button { padding: 10px; font-size: 16px; } button:hover { background-color: #28a745; } #result { background-color: #e9f7ef; padding: 15px; border-radius: 8px; box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1); } #result span { font-weight: bold; color: #007bff; } document.getElementById('taxForm').addEventListener('submit', function(event) { event.preventDefault(); // Get the values from the input fields const price = parseFloat(document.getElementById('price').value); const taxRate = parseFloat(document.getElementById('taxRate').value); // Validate inputs if (isNaN(price) || price <= 0 || isNaN(taxRate) || taxRate < 0) { alert('Please enter valid price and tax rate.'); return; } // Calculate the tax and total const taxAmount = (price * taxRate) / 100; const totalAmount = price + taxAmount; // Display results document.getElementById('result').style.display = 'block'; document.getElementById('resultPrice').textContent = price.toFixed(2); document.getElementById('resultTax').textContent = taxAmount.toFixed(2); document.getElementById('resultTotal').textContent = totalAmount.toFixed(2); });