// Define the base price for each product const productA = 100; const productB = 200; const productC = 300; // Define the additional cost for each feature const featureX = 50; const featureY = 75; const featureZ = 100; // Initialize the total cost let totalCost = 0; // Function to calculate the final invoice function calculateInvoice() { // Get the selected product from the dropdown menu const product = document.getElementById("product").value; // Determine the base cost based on the selected product switch (product) { case "A": totalCost = productA; break; case "B": totalCost = productB; break; case "C": totalCost = productC; break; default: totalCost = 0; } // Check if each feature is selected and add the additional cost if necessary if (document.getElementById("featureX").checked) { totalCost += featureX; } if (document.getElementById("featureY").checked) { totalCost += featureY; } if (document.getElementById("featureZ").checked) { totalCost += featureZ; } // Display the final cost document.getElementById("totalCost").innerHTML = "Total Cost: $" + totalCost; }

Header Ads

Football

Basketball

Ad Home

No posts.
No posts.

Tennis

Racing

Powered by Blogger.
// Define the base price for each product const productA = 100; const productB = 200; const productC = 300; // Define the additional cost for each feature const featureX = 50; const featureY = 75; const featureZ = 100; // Initialize the total cost let totalCost = 0; // Function to calculate the final invoice function calculateInvoice() { // Get the selected product from the dropdown menu const product = document.getElementById("product").value; // Determine the base cost based on the selected product switch (product) { case "A": totalCost = productA; break; case "B": totalCost = productB; break; case "C": totalCost = productC; break; default: totalCost = 0; } // Check if each feature is selected and add the additional cost if necessary if (document.getElementById("featureX").checked) { totalCost += featureX; } if (document.getElementById("featureY").checked) { totalCost += featureY; } if (document.getElementById("featureZ").checked) { totalCost += featureZ; } // Display the final cost document.getElementById("totalCost").innerHTML = "Total Cost: $" + totalCost; }