Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
10-09-2008, 05:31 PM #1
- Join Date
- Oct 2008
- Thanked 0 Times in 0 Posts
need help with setting up a input to calculate costs of certain products!!
i have made three prompt boxes asking the customer what product he would like, the price, and the discount. now this is where i get lost, how do i take an input for the quantity of the product required? The message to the customer should say "How many of [product name] would you like?". i will then use the product name variable in place of [product name]. i want these inputs to calculate the cost of my product.
10-09-2008, 07:30 PM #2
Might want to add additional checks of input to avoid NaN errors.PHP Code:
var productName = document.getElementById('ProductName").value; // unit cost of product
var productQuan = document.getElementById('ProductQuan").value; // quantity desired
var productCost = Number(productName) * Number(productQuan);
document.getElementById('ProductCost').value = productCost.toFixed(2);