soaring206
12-19-2004, 09:00 AM
I'm trying to write a program that will allow users to order pizza online and enter the desired number of toppings for each pizza. I think I have the entire thing running correctly except that instead of adding the number of toppings for each pizza together to get a total number of toppings, it's just stringing them together. For example, if someone enters that they want 4 pizzas with 1, 3, 2, and 5 toppings, instead of returning a topping value of 11, it returns 5231. The function that contains this step is below...could someone please tell me where I'm going wrong and point me in the right direction? I didn't want to post too much code, but if you need more information, please reply and I can post as much of the code as you want to see. Thank you!
function toppings()
{var pizza1 = parseFloat(document.pizza_order.pizzas.value);
var message;
var x = 1;
var i;
var topping_no;
for(i=x; i<=pizza1; i++)
{message = "Please enter the desired number of toppings for pizza " + (x=i) + "";
topping_no = parseFloat(prompt(message, "0") + topping_no);}
return topping_no;}
function toppings()
{var pizza1 = parseFloat(document.pizza_order.pizzas.value);
var message;
var x = 1;
var i;
var topping_no;
for(i=x; i<=pizza1; i++)
{message = "Please enter the desired number of toppings for pizza " + (x=i) + "";
topping_no = parseFloat(prompt(message, "0") + topping_no);}
return topping_no;}