I have a form generated dynamicaly with inerHTML with the following structure
| price1 | | tax1 |
| price2 | | tax2 |
etc.
the 1,2,.. are dynamicaly generated
price is a number the user fills in
tax is a selection field and can either be 20% or 0%
What i want is to calculate the sum of all prices where tax=20%
I tried some different options but get no result.
function sum20(frm) {
var price_tot=0;
for(var i=0;bot=frm["tax"+i];i++){
if(bot.value=="20%") {
var intot = frm['price'+i].value * 1;
if(!isNaN(intot)) price_tot = price_tot + intot;
}
}
frm.total20.value = price_tot;
}
| price1 | | tax1 |
| price2 | | tax2 |
etc.
the 1,2,.. are dynamicaly generated
price is a number the user fills in
tax is a selection field and can either be 20% or 0%
What i want is to calculate the sum of all prices where tax=20%
I tried some different options but get no result.
function sum20(frm) {
var price_tot=0;
for(var i=0;bot=frm["tax"+i];i++){
if(bot.value=="20%") {
var intot = frm['price'+i].value * 1;
if(!isNaN(intot)) price_tot = price_tot + intot;
}
}
frm.total20.value = price_tot;
}