Sorry but I need a bit of help again

admin

Administrator
Staff member
I am trying to make a varible increment itself by a certain amount in a loop.

It's for part of an order form.

This is part of the script....

itemlist = 0;
for (i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == '[') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == ']') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
totprice = totprice + itemtotal;
blendtot = blendtot + thequantity;
itemlist=itemlist+1;

etc............

What I want to do is have the variable called blendtot increase itself by thequantity each time it goes through the loop.
The way I see it, blendtot = blendtot + thequantity should mean that if there where 3 items in the order, and for each item there was just 1 of them, that would mean 3 items in all, which means that blendtot should also = 3, because thequantity = 1 for each loop (3 loops in all (if 3 items are ordered)).
The variable thequantity is the amount of each item ordered, so if there are 3 items ordered, and there are 2 of the first item, 2 of the second item and 5 of the third item then that makes 9 items in total.
According to blendtot = blendtot + thequantity blendtot should = 9.
Hope this makes sence.

Anyway I have written the script so that I can see the value for blendtot and instead of it printing 3 it's printing 111.
It seem to be dispalying the 3 one's rather than adding them together.

Any ideas?

Thank you.
 
Back
Top