Jump to content

Sum Number of Textboxes Values?


barkster

Recommended Posts

Cool that worked, though had to do it this way. For some reason when it was adding the values it was adding 2+3 as 23 instead of 5.

 

Thanks

 

var totalcomp = 0;

var totalbill = 0;

for(i=0; i<document.forms[0].elements.length; i++){

    var n = document.forms[0].elements.name;

    if (n.indexOf("tbbtime")>=0) {

    var v = parseFloat(document.forms[0].elements.value);

    totalbill = totalbill + v;

    }

    else if (n.indexOf("tbctime")>=0) {

    var v = parseFloat(document.forms[0].elements.value);

    totalcomp = totalcomp + v;

    }

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.