Apologies for the horrendous title. Really difficult to summarize this problem and it is actually a javascript/AJAX issue eventually so I don't think I'm in the wrong forum.

What I have is a query that outputs sizes and weights of an object from fields in the table. All are user inputs. It then calculates the best way to package these and calculates a delivery cost. That could be a tricky bit, but it works perfectly. I finish up with a variable called $fincharge. I have done this with php passed back through AJAX to the page (for want of a better way of phrasing this).

Naturally, real-life also requires that I can deal with multiple items per delivery, so I effectively finish with several $fincharge(s) in a php do .. while formatted on the page.

Usually when I have to calculate totals, I create a total column in the MySQL query, however in this case the deliveries are calculated on the fly. Whilst I could create the charge and update the table in a new field, that's slow and cumbersome. Can anybody suggest a way to use javascript to total every $fincharge? Bear in mind that it is impossible to forecast how many items the user will order, so this means that I can't use different id's on page elements. Perhaps, I could hijack the XMLHttp_response and use the function for my total instead of the page elements.

I think that makes sense, but sometimes when you're close to a problem, it's hard to explain clearly.