I am trying to use the following function to search for values in form fields. The reason its loops are because the form changes dynamically, which means there may be spaces in the field identifier
Java script function
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
onchange='totalProductPrice();'
When I change the value of this field, it must compose all the fields and then insert them into the QUOTTotalcost field, but when I try it, nothing happens. In the console firebug gives
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;
source
share