Hi,
Im trying to use the below function to find values in form fields, The reason its loops is because the form changes dynamically which means there could be gaps in the ID of the field
Java script function is
function totalProductPrice() {
var maxid = document.getElementById("field_id").value;
var i = 0;
var totalprice = 0;
while (i<=maxid)
{
totalprice += document.getElementById("QuoteItem" + i + "price").value;
i++;
}
document.getElementById("QuoteTotalcost").value = totalprice;
}
and then on one of the input fields i have
onchange='totalProductPrice();'
When i change the value of this field it should add up all the fields and then insert it into the field called QUoteTotalcost but when i try it does nothing, In the console of firebug it outputs
element.dispatchEvent is not a function
[Break on this error] element.dispatchEvent(event);
prototype.js (line 4619)
document.getElementById("QuoteItem" + i + "price") is null
[Break on this error] totalprice += document.getElementById("QuoteItem" + i + "price").value;