
function calculateTotal() {
    const quantity = document.getElementById('quantity').value;
    const price = document.getElementById('price').value;
    const totalPrice = quantity * price;
    document.getElementById('totalPrice').value = totalPrice ? totalPrice.toFixed(2) : '';
}

function addProduct() {
    const productId = document.getElementById('productId').value;
    const productName = document.getElementById('productName').value;
    const quantity = document.getElementById('quantity').value;
    const price = document.getElementById('price').value;
    const totalPrice = document.getElementById('totalPrice').value;

    if (productId && productName && quantity > 0 && price > 0) {
        alert(`Product Added: 
        \nProduct ID: ${productId}
        \nProduct Name: ${productName}
        \nQuantity: ${quantity}
        \nPrice per Unit: $${parseFloat(price).toFixed(2)}
        \nTotal Price: $${totalPrice}`);
        
        // Clear form fields after adding product
        document.getElementById('productForm').reset();
        document.getElementById('totalPrice').value = ''; // Clear the total price field
    } else {
        alert("Please fill in all the fields with valid values.");
    }
}