I have a section called background which can have various user inputed values. And I want to add all the values but cannot seem to get it to work, there might be a typo or something of the kind since I only copy and paste the example on this " <a href="https://wiki.roll20.net/RepeatingSum" rel="nofollow">https://wiki.roll20.net/RepeatingSum</a> " //Handle advantages/disadvantages cost const bTotal = ['advantage_total', 'disadvantage_total']; const bSection = ['advantage', 'disadvantage']; const bCosts = 'advantage_cost'; const repeatingSum = (bTotal, bSection, bCosts) => { if (!Array.isArray(bTotal)) bTotal = [bTotal.replace(/\s/g, '').split(',')]; if (!Array.isArray(bCosts)) bCosts = [bCosts.replace(/\s/g, '').split(',')]; getSectionIDs(`repeating_${bSection}`, idArray => { const attrArray = idArray.reduce((m, id) => [...m, ...(bCosts.map(field => `repeating_${bSection}_${id}_$ {field}`))], []); getAttrs([...attrArray], v => { const getValue = (bSection, id, field) => v[`repeating_${bSection}_${id}_${field}`] === 'on' ? 1 : parseFloat(v[`repeating_${bSection}_${id}_${field}`]) || 0; const commonMultipliers = (bCosts.length <= bTotal.length) ? [] : bCosts.splice(bTotal.length, bCosts.length - bTotal.length); const output = {}; bTotal.forEach((destination, index) => { output[destination] = idArray.reduce((total, id) => total + getValue(bSection, id, bCosts[index]) * commonMultipliers.reduce((subtotal, mult) => subtotal * getValue(bSection, id, mult), 1), 0); }); setAttrs(output); }); }); }; on('change:repeating_advantage:advantage_cost', function() { repeatingSum("advantage_total", "advantage_cost"); }); HTML < div class = "advantages" > < h1 > Ventajas </ h1 >< br > < input type = "number" name = "attr_advantage_total" readonly /> < fieldset class = "repeating_advantage" > < select name = "attr_advantage" > <...> < input type = "number" name = "attr_advantage_cost" value = "1" > < div class = "advantageData" > < textarea name = "attr_advantage" ></ textarea > </ div > </ fieldset > </ div >