Hi!
I have a javascript function that loops through certain elements on a page and add's the elements up.
For example, element 1 value is 20 and element 2 value is 10. The alert in the loop should be showing 20 and then 10, but it just shows undefined20.00 and the stops?
Here is my function...
function updatePrice(couponPrice,couponQuanity,whichPrice,howMany) {
var price = couponPrice * couponQuanity;
var x;
var ptotal;
var myItems = new Array();
document.getElementById(whichPrice).innerHTML=price.toFixed(2);
for (x=1;x<howMany+1;x++) {
myItems[x] = document.getElementById('totalPrice' + x).innerHTML;
ptotal+=myItems[x];
alert(ptotal);
}
}