Free Online Invoice Generator | Quick & Professional Invoices
Free Online Invoice Generator
Item |
Quantity |
Price |
Total |
|
Total: $0.00
© 2023 Invoice Generator. All rights reserved.
`;
}
// Invoice Generator Logic
let items = [];
function addItem() {
items.push({ name: '', quantity: 1, price: 0 });
renderItems();
}
function updateItem(index, field, value) {
items[index][field] = field === 'name' ? value : Number(value);
calculateTotal();
}
function calculateTotal() {
const total = items.reduce((sum, item) => sum + (item.quantity * item.price), 0);
document.getElementById('totalAmount').textContent = total.toFixed(2);
}
function renderItems() {
const tbody = document.querySelector('#itemsTable tbody');
tbody.innerHTML = items.map((item, index) => `
|
|
|
$${(item.quantity * item.price).toFixed(2)} |
|
`).join('');
calculateTotal();
}
function deleteItem(index) {
items.splice(index, 1);
renderItems();
}
function generatePDF() {
window.print();
}
// Search Functionality
document.getElementById('searchInput').addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
const tools = document.querySelectorAll('.tool-card');
tools.forEach(tool => {
const title = tool.querySelector('.card-title').textContent.toLowerCase();
tool.style.display = title.includes(searchTerm) ? 'block' : 'none';
});
});
// Initialize Tools Grid
function initTools() {
const tools = [
{ name: 'Expense Tracker', category: 'Finance' },
{ name: 'Tax Calculator', category: 'Finance' },
{ name: 'Receipt Generator', category: 'Documents' },
{ name: 'Time Tracking', category: 'Productivity' }
];
const grid = document.getElementById('toolsGrid');
grid.innerHTML = tools.map(tool => `
`).join('');
}
// Initialize Page
window.onload = function() {
loadHeaderFooter();
initTools();
addItem(); // Add initial empty item
};