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

Unable to delete fieldset entries

As title suggests. I'm working on this code. Problem (in game): I can't delete fieldsets after I create them. I can delete older sets I've created before modding them today, but newer ones refuse to delete. My hypothesis: Originally this section (the code below) was a catchall "Starship parts" section with 4 primary subcategories "Blueprints, Chassis, Integrated, and Systems" Today I started modifying it so that there are 3 sections for Chassis, Integrated, and Systems with a "Show/Hide" option to each section.  ^ This is where the start of the problem occurred. If I remove the 3 sections and leave it as 1 giant section, it works normally. Hopefully this helps narrow the problem down. Solution I'm seeking: Point me in the direction to make this function properly, add function works, the delete function does not. Thank you for the time and help! Note 1: This is not my code, I am reverse-engineering and modifying someone else's work for my game. The original sheet template is meant for Star Wars D20, which I am using it but modded heavily. Note 2: I am a novice *self-taught* programmer, using acquired knowledge and no professional training. Giving me directions with technical babble and no appendix or definitions will just confuse me. Note 3: I know spans are better than tables, getting official approval from Roll20, blah blah blah. I don't care, I just want this code to work so my player's have a better experience playing Star Wars D&D. <div> <table cellpadding="10" cellspacing="0"> <tr> <td colspan="3" class="sheet-statlabel-big-gray" style="font-size: 1.5em; width: 450px;">Starship Chassis parts</td> </tr> </table> <input name="attr_simplechassis" type="checkbox" class="reveal"> <span>Hide/Show Chassis parts</span> <div class="reveal"> <fieldset class="repeating_starfighter"> <table cellpadding="0" cellspacing="0"> <tr> <td class="sheet-statlabel" style="font-size: 0.65em; width: 200px;">Part Name</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 100px;">Category</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 100px;">Type</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 40px;">Link</td> </tr> <tr> <td><input class="sheet-inputbox" type="text" name="attr_starpartname" style="height: 24px; width: 200px;"></td> <td><select style="height: 24px; width: 120px;" name="attr_starcata"> <option >Armor</option> <option >Automation</option> <option >Capacitor</option> <option >Computer</option> <option >Consumables</option> <option >Crew</option> <option >Engines</option> <option >Hyperdrive</option> <option >Life Support</option> <option >Reactor</option> <option >Shields</option> <option >Stowage</option> <option >Passengers</option> <option >Program</option> <option >Weapons</option> <option >Other</option> </select></td> <td><select style="width: 120px;" name="attr_startype"> <option >Blueprint</option> <option >Chassis</option> <option >Systems</option> <option >Integrated</option> </select> </td> <td><button type="roll" value="@{whisper}&{template:SW20default} {{name=@{starpartname}}} {{source=@{starcata}, @{startype}, @{sysstatus}}} {{description=@{starshipmod_notes}}}" name="roll_postspart1"></button></td> </tr> <tr> <td></td> <td></td> <td><select style="height: 24px; width: 120px;" name="attr_sysstatus"> <option style="background-color: #0F0;" >Online</option> <option style="background-color: #F00;" >Offline</option> </select></td> </tr> </table> <table cellpadding="10" cellspacing="0"> <tr> <td colspan="3" class="sheet-statlabel-big-gray" style="font-size: 1.5em; width: 450px;">Starship Part Mods</td> </tr> </table> <textarea name="attr_starshipmod_notes" style="width: 460px; height: 25px;"></textarea> </fieldset> <br><br> </div></div> <div> <table cellpadding="10" cellspacing="0"> <tr> <td colspan="3" class="sheet-statlabel-big-gray" style="font-size: 1.5em; width: 450px;">Starship Integrated parts</td> </tr> </table> <input name="attr_simpleintegrated" type="checkbox" class="reveal"> <span>Hide/Show Integrated parts</span> <div class="reveal"> <fieldset class="repeating_starfighter_Integrated"> <table cellpadding="0" cellspacing="0"> <tr> <td class="sheet-statlabel" style="font-size: 0.65em; width: 200px;">Part Name</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 100px;">Category</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 100px;">Type</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 40px;">Link</td> </tr> <tr> <td><input class="sheet-inputbox" type="text" name="attr_starpartname2" style="height: 24px; width: 200px;"></td> <td><select style="height: 24px; width: 120px;" name="attr_starcata2"> <option >Armor</option> <option >Automation</option> <option >Capacitor</option> <option >Computer</option> <option >Consumables</option> <option >Crew</option> <option >Engines</option> <option >Hyperdrive</option> <option >Life Support</option> <option >Reactor</option> <option >Shields</option> <option >Stowage</option> <option >Passengers</option> <option >Program</option> <option >Weapons</option> <option >Other</option> </select></td> <td><select style="width: 120px;" name="attr_startype"> <option >Blueprint</option> <option >Chassis</option> <option >Systems</option> <option >Integrated</option> </select> </td> <td><button type="roll" value="@{whisper}&{template:SW20default} {{name=@{starpartname2}}} {{source=@{starcata2}, @{startype2}, @{sysstatus2}}} {{description=@{starshipmod_notes2}}}" name="roll_postspart2"></button></td> </tr> <tr> <td></td> <td></td> <td><select style="height: 24px; width: 120px;" name="attr_sysstatus2"> <option style="background-color: #0F0;" >Online</option> <option style="background-color: #F00;" >Offline</option> </select></td> </tr> </table> <table cellpadding="10" cellspacing="0"> <tr> <td colspan="3" class="sheet-statlabel-big-gray" style="font-size: 1.5em; width: 450px;">Starship Part Mods</td> </tr> </table> <textarea name="attr_starshipmod_notes2" style="width: 460px; height: 25px;"></textarea> </fieldset> </div></div> <div> <table cellpadding="10" cellspacing="0"> <tr> <td colspan="3" class="sheet-statlabel-big-gray" style="font-size: 1.5em; width: 450px;">Starship System parts</td> </tr> </table> <input name="attr_simplesystems" type="checkbox" class="reveal"> <span>Hide/Show System parts</span> <div class="reveal"> <fieldset class="repeating_starfighter_System"> <table cellpadding="0" cellspacing="0"> <tr> <td class="sheet-statlabel" style="font-size: 0.65em; width: 200px;">Part Name</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 100px;">Category</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 100px;">Type</td> <td class="sheet-statlabel" style="font-size: 0.65em; width: 40px;">Link</td> </tr> <tr> <td><input class="sheet-inputbox" type="text" name="attr_starpartname3" style="height: 24px; width: 200px;"></td> <td><select style="height: 24px; width: 120px;" name="attr_starcata3"> <option >Armor</option> <option >Automation</option> <option >Capacitor</option> <option >Computer</option> <option >Consumables</option> <option >Crew</option> <option >Engines</option> <option >Hyperdrive</option> <option >Life Support</option> <option >Reactor</option> <option >Shields</option> <option >Stowage</option> <option >Passengers</option> <option >Program</option> <option >Weapons</option> <option >Other</option> </select></td> <td><select style="width: 120px;" name="attr_startype3"> <option >Blueprint</option> <option >Chassis</option> <option >Systems</option> <option >Integrated</option> </select> </td> <td><button type="roll" value="@{whisper}&{template:SW20default} {{name=@{starpartname3}}} {{source=@{starcata3}, @{startype3}, @{sysstatus3}}} {{description=@{starshipmod_notes3}}}" name="roll_postspart3"></button></td> </tr> <tr> <td></td> <td></td> <td><select style="height: 24px; width: 120px;" name="attr_sysstatus3"> <option style="background-color: #0F0;" >Online</option> <option style="background-color: #F00;" >Offline</option> </select></td> </tr> </table> <table cellpadding="10" cellspacing="0"> <tr> <td colspan="3" class="sheet-statlabel-big-gray" style="font-size: 1.5em; width: 450px;">Starship Part Mods</td> </tr> </table> <textarea name="attr_starshipmod_notes3" style="width: 460px; height: 25px;"></textarea> </fieldset> </div></div> And here's my function section: <script type="text/worker"> const buttonlist = ["meleesheet1","rangesheet1","armorsheet1", "inventsheet1", "featsheet1", "buffsheet1", "relsheet1", "abilitysheet1", "starshipsheet1", "speedersheet1", "titlesheet1", "factionsheet1"]; buttonlist.forEach(button => { on(`clicked:${button}`, function() { setAttrs({ sheetTab: button }); }); }); function hideFunction() { var x = document.getElementById("hideDIV"); if (x.style.display === "none") { x.style.display = "grid"; } else { x.style.display = "none"; } } /* ===== PARAMETERS ========== destinations = the name of the attribute that stores the total quantity can be a single attribute, or an array: ['total_cost', 'total_weight'] If more than one, the matching fields must be in the same order. section = name of repeating fieldset, without the repeating_ fields = the name of the attribute field to be summed destination and fields both can be a single attribute: 'weight' or an array of attributes: ['weight','number','equipped'] */ const repeatingSum = (destinations, section, fields) => { if (!Array.isArray(destinations)) destinations = [destinations.replace(/\s/g, '').split(',')]; if (!Array.isArray(fields)) fields = [fields.replace(/\s/g, '').split(',')]; getSectionIDs(`repeating_${section}`, idArray => { const attrArray = idArray.reduce((m, id) => [...m, ...(fields.map(field => `repeating_${section}_${id}_${field}`))], []); getAttrs([...attrArray], v => { const getValue = (section, id, field) => v[`repeating_${section}_${id}_${field}`] === 'on' ? 1 : parseFloat(v[`repeating_${section}_${id}_${field}`]) || 0; const commonMultipliers = (fields.length <= destinations.length) ? [] : fields.splice(destinations.length, fields.length - destinations.length); const output = {}; destinations.forEach((destination, index) => { output[destination] = idArray.reduce((total, id) => total + getValue(section, id, fields[index]) * commonMultipliers.reduce((subtotal, mult) => subtotal * getValue(section, id, mult), 1), 0); }); setAttrs(output); }); }); }; on('change:repeating_inventorylist remove:repeating_inventorylist', function() { repeatingSum("encumbrance_total","inventorylist",["gearitemwt","gearitemQT"]); }); </script>
1694196406
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Repeating section names cannot have underscores in the name of the section (e.g. starfighter_system). You need to use kebab-case for those (this of course does not apply to the repeating_  part of the repeating section name.
Scott C. said: Repeating section names cannot have underscores in the name of the section (e.g. starfighter_system). You need to use kebab-case for those (this of course does not apply to the repeating_  part of the repeating section name. Awesome. Thanks!