Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Hardcoding totals from a repeating section - possible? If so how?

1476007530

Edited 1476007581
Pat S.
Forum Champion
Sheet Author
I have a repeating section for my equipment list and I want to show a running total of the weight. How can I do this? This is the total weight display code and I have it set at value="0" for now. <div class="sheet-col-1-4 sheet-center"><input type="number" name="attr_inventory_weight" value="0"></div> This is one of the fieldset codes for the tabs (I have another one) that I want to pull from. The "attr_itemwornenc" is the weight input. <fieldset class="repeating_inventtab1"> <div class="sheet-row"> <div class="sheet-col-1-4 sheet-small-label sheet-left"><input type="text" name="attr_itemname"></div> <div class="sheet-col-1-12 sheet-padl sheet-center"><input type="number" name="attr_itemquantity"></div> <div class="sheet-col-1-12 sheet-padl sheet-center"><input type="number" name="attr_itemuses"></div> <div class="sheet-col-1-12 sheet-padl sheet-center"><input type="number" name="attr_itemwornenc"></div> <div class="sheet-col-1-2 sheet-padl sheet-small-label sheet-left"><input type="text" name="attr_itemdesc"></div> </div> </fieldset> The other repeating fieldset (repeating_inventtab2) is identical except that the input name that I wish to pull from is "attr_itemcarriedenc". My goal is to have a default start value "0" but as players add equipment or gear to their character's sheet, it tracks the weight total. I have not figured out how to do that. Any suggestions or ideas?
1476009806
Finderski
Pro
Sheet Author
Compendium Curator
I use TheAaronSheetwork for all my summing needs. :) <a href="https://app.roll20.net/forum/post/2876287/slug}#post-2946174" rel="nofollow">https://app.roll20.net/forum/post/2876287/slug}#post-2946174</a>
1476013682
Pat S.
Forum Champion
Sheet Author
Finderski said: I use TheAaronSheetwork for all my summing needs. :) <a href="https://app.roll20.net/forum/post/2876287/slug}#post-2946174" rel="nofollow">https://app.roll20.net/forum/post/2876287/slug}#post-2946174</a> I wish I knew what that was but I'm not a coder so just doing the sheet has been a struggle.
1476033651
Lithl
Pro
Sheet Author
API Scripter
TAS is a set of utility methods for sheet worker scripts. In particular, it has useful functions for handling repeating sections, and IIRC is has one that's specifically to sum an attribute across repeating items, exactly what you're looking for.
1476034676

Edited 1476034851
Pat S.
Forum Champion
Sheet Author
I just don't know anything about&nbsp; sheet workers but I am reading it.
1476066508
Finderski
Pro
Sheet Author
Compendium Curator
&nbsp; The TAS makes it easy to do what you want. Here's how it works in my sheet... &lt;!-- SHEET WORKERS --&gt; &lt;script type="text/worker"&gt; /*the TAS sheet worker code goes here—just cut & paste the whole thing*/ // Calculate Armor Weights on('change:repeating_armor remove:repeating_armor',function(){ TAS.repeatingSimpleSum('armor','ArmorTypeWeight','armortotalweightcarried'); }); // Calculate Melee Weapon Weights on('change:repeating_meleeweapons remove:repeating_meleeweapons',function(){ TAS.repeatingSimpleSum('meleeweapons','WeaponWeight','meleetotalweightcarried'); }); // Calculate Range Weapon Weights on('change:repeating_rangeweapons remove:repeating_rangeweapons',function(){ TAS.repeatingSimpleSum('rangeweapons','RWeaponWeight','rangedtotalweightcarried'); }); // Calculate Gear Weights on('change:repeating_gear remove:repeating_gear',function(){ TAS.repeatingSimpleSum('gear','itemWeight','geartotalweightcarried'); }); &lt;/script&gt; Here's my repeating section for Gear: &lt;fieldset class="repeating_gear"&gt; &lt;input class="sheet-standard" placeholder="Item" type="text" name="attr_item" /&gt; &lt;input type="number" placeholder="weight" name="attr_itemWeight" class="sheet-standardNum" /&gt; &lt;/fieldset&gt; The other repeating sections are similarly set up, with different input field names of course.