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

Performing Math with repeating sections.

Hello, I have an advancement section on my character sheet that I was looking to do some math with.  Essentially, I have a game that you pay for character improvemens with experience points.  I have a repeating section that tracks said advancements and their costs.  I want to TOTAL those advancements in the repeating section and store that as an attribute so I can use OUTSIDE the repeating section using sheet workers.  I was hoping someone might be able to show me how this would be done an then explain the code. Here is the code I have for the HTML of the repeating section. <!-- @{XPSpent} is the amount totaled from the repeating sections. --> <div class="sheet-row">                 <div class="sheet-item" style="width:12%">                     <label data-i18n="xptospend">XP to Spend:</label>                 </div>                 <div class="sheet-item" style="width:10%">                     <input  name="attr_XPtoSpend" type="number" class="sheet-xp" value="@{XPTotal} - @{XPSpent}" disabled />                 </div>                 <div class="sheet-item" style="width:1%"></div> <div class="sheet-item" style="width:10%">                     <label data-i18n="totalxpspent">Total Spent:</label>                 </div>                 <div class="sheet-item" style="width:15%">                     <input name="attr_XPSpent" type="number" class="sheet-xp" value="0" readonly />                 </div>                 <div class="sheet-item" style="width:1%"></div>                 <div class="sheet-item" style="width:5%">                     <label data-i18n="totalxp">Total:</label>                 </div> <div class="sheet-item" style="width:10%">                     <input type="number" name="attr_XPTotal" class="sheet-xp" value="0" />                 </div> <div class="sheet-item" style="width:10%">                     <label>Exp Debt:</label>                 </div>                 <div class="sheet-item" style="width:25%">                     <input type="number" name="attr_XPDebt" class="sheet-xp" value="0" />                 </div>                 <label data-i18n="advancementtaken:">Advancements Taken:</label>                 <fieldset class="repeating_advancements">                     <div class="sheet-row">                         <div class="sheet-item" style="width:26%;">                             <input name="attr_advancement1" type="text">                         </div>                         <div class="sheet-item sheet-puny sheet-center sheet-brackets sheet-armourblock">                             <input name="attr_advancement1xp" type="text">                         </div>                         <div class="sheet-item" style="width:26%;">                             <input name="attr_advancement2" type="text">                         </div>                         <div class="sheet-item sheet-puny sheet-center sheet-brackets sheet-armourblock">                             <input name="attr_advancement2xp" type="text">                         </div>                         <div class="sheet-item" style="width:26%;">                             <input name="attr_advancement3" type="text">                         </div>                         <div class="sheet-item sheet-puny sheet-center sheet-brackets sheet-armourblock">                             <input name="attr_advancement3xp" type="text">                         </div>                     </div>                 </fieldset>                 <hr>                 <h3 data-i18n="othernotes:">Other Notes:</h3>                 <textarea name="attr_othernotes">             </textarea>             </div><!-- Charsheet End --> I do also want to use this elsewhere on the character sheet, for gear weights and cost as well, but I'm hoping I can use this code, get an understanding from it and do those on my
1663650724
Kraynic
Pro
Sheet Author
I'm not sure I have my head wrapped around exactly what you want to do with the xp, but have you looked at the Repeating Sum sheetworker example on the wiki?&nbsp; It should give you a framework for calculating totals of weights and such.&nbsp; If all you want to do is total points spent on things, it should work just the same. <a href="https://wiki.roll20.net/RepeatingSum" rel="nofollow">https://wiki.roll20.net/RepeatingSum</a>