var k, i, total_m, total_l ,
boxes = [
['A', 'B', 'C', 'D'],
['F', 'G', 'H', 'J'],
['K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T']
];
for( k = 0; k < boxes.length; k++ ) {
total_m = 0;
total_l = 0;
for( i = 0; i < boxes[ k ].length; i++ ) {
total_m += parseFloat(document.getElementById("input" + boxes[ k ][ i ]).value.replace(/,/, '.')) || 0;
total_l += parseFloat(document.getElementById("output" + boxes[ k ][ i ]).value.replace(/,/, '.')) || 0;
}
document.getElementById("total_box" + k + "_m").value = total_m;
document.getElementById("total_box" + k + "_l").value = total_l;
}
<input id="total_box0_m" size="8"/>
<input id="total_box0_l" size="8"/>
<input id="total_box1_m" size="8"/>
<input id="total_box1_l" size="8"/>
<input id="total_box2_m" size="8"/>
<input id="total_box2_l" size="8"/>