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

Action button in Repeating Section (again >_>)

1612602990

Edited 1612603964
Oliver
Sheet Author
Hello guys I've checked many topics on how to handle action button in a Repeating section, but it seems i just can't figure it out T_T Example : I have repeating sections for bottles. In each section we have checkboxes, representing the remaining water. I have an "emptyBottle " action button to uncheck all chackboxes, all at once, to save some time. Here's the code so far, with only 2 checkboxes for convenience purposes ^^" : on("clicked:repeating_bottles:emptyBottle", function(eventInfo) { const rowid = eventInfo.sourceAttribute.split('_')[2]; setAttrs({ ["repeating_bottles_"+rowid+"_checkbox0"]:0, ["repeating_bottles_"+rowid+"_checkbox1"]:0, "repeating_bottles_showrowid":rowid }); }); It simply does nothing. but if i replace on("clicked:repeating_bottles:emptyBottle" by on("change:repeating_bottles:textInputBottle" then the first code, at the top, works pretty fine... I'm lost, could someone help me with this one? Thank you guys :)
1612605132
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
can you post the code of the repeating field? (as a sidenote, if the button does not work  you can make suck that if you uncheck the first check box in a series inside the repeating section the code would uncheck all... it might sidestep your button problem :) ) I used something like this, where each box had a value equal to a power of 10(if you have a small number of checkbox, it's a useful hack ;) ) on("change:check_violence_1 change:check_violence_2 change:check_violence_3 change:check_helplessness_1 change:check_helplessness_2 change:check_helplessness_3",function(){ getAttrs(['check_violence_1', 'check_violence_2','check_violence_3','check_helplessness_1', 'check_helplessness_2','check_helplessness_3'],function(v){ const v1=parseInt(v.check_violence_1,10)||0; const v2=parseInt(v.check_violence_2,10)||0; const v3=parseInt(v.check_violence_3,10)||0; let vold=adaptv.reduce(getSum); adaptv[0]=v1; adaptv[1]=v2; adaptv[2]=v3; let Sv=adaptv.reduce(getSum,0); const h1=parseInt(v.check_helplessness_1,10)||0; const h2=parseInt(v.check_helplessness_2,10)||0; const h3=parseInt(v.check_helplessness_3,10)||0; let hold=adapth.reduce(getSum,0); adapth[0]=h1; adapth[1]=h2; adapth[2]=h3; let Sh=adapth.reduce(getSum,0); if (Sv>vold){ if (Sv>=10){ setAttrs({check_violence_1: '1'}); } if (Sv>=100){ setAttrs({check_violence_2: '10'}); } } if (Sv<vold){ if (Sv<=110){ setAttrs({check_violence_3: 0}); } if (Sv<=10){ setAttrs({check_violence_2: 0}); } } if (Sh>hold){ if(Sh>=10){ setAttrs({check_helplessness_1: '1'}); } if (Sh>=100){ setAttrs({check_helplessness_2: '10'}); } } if (Sh<hold){ if (Sh<=110){ setAttrs({check_helplessness_3: 0}); } if(Sh<=10){ setAttrs({check_helplessness_2: 0}); } } }); });
1612609777

Edited 1612619553
Oliver
Sheet Author
Thank you for your answer :) I've already considered several workarounds, but I wonder why i can't make the action button work in Repeating sections...I've already seen several topics where people just manage to do it in the end (but there were no checkboxes involved, iirc). Here's the html fieldset code. <fieldset class="repeating_bottles">     <div style="width:750px; height:100px;">         <button type="action" class="button-bottles-uncheck" name="act_emptyBottle" style="text-align:center;width:50;height:51px;"></button>                  <input type="checkbox" name="attr_checkbox0" value="1">         <input type="checkbox" name="attr_checkbox1" value="1">         <input type="checkbox" name="attr_checkbox2" value="1">         <input type="checkbox" name="attr_checkbox3" value="1">         <input type="checkbox" name="attr_checkbox4" value="1">         <input type="checkbox" name="attr_checkbox5" value="1">         <input type="checkbox" name="attr_checkbox6" value="1">         <input type="checkbox" name="attr_checkbox7" value="1">         <input type="checkbox" name="attr_checkbox8" value="1">         <input type="checkbox" name="attr_checkbox9" value="1">                  <input type="text" name="attr_textInputBottle" style="width:200px;"> // for debug purpose         <input type="text" name="attr_showrowid" style="width:200px;"> // for row id info </div> </fieldset>
1612617557

Edited 1612617921
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
have you tried to do just&nbsp; on("clicked:repeating_bottles:emptyBottle", function(eventInfo) { setAttrs({ "repeating_bottles_checkbox0":0, "repeating_bottles_checkbox1":0, }); }); Values in repeating sections require a little special handling. If the event that you are inside of is already inside of a repeating section, you can simply request the variable using its name prefaced by the repeating group name and you will receive the value in the same repeating section the event was triggered in. <a href="https://wiki.roll20.net/Sheet_Worker_Scripts" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts</a>
1612632729

Edited 1612632792
GiGs
Pro
Sheet Author
API Scripter
To add to the previous post, property names on the event line must always be lower cased, so try this: on("clicked:repeating_bottles:emptybottle", function(eventInfo) { setAttrs({ "repeating_bottles_checkbox0":0, "repeating_bottles_checkbox1":0, }); }); This is most likely why the code in your first post wasnt working.
1612642367
Oliver
Sheet Author
-__- omg the lower case solved everything xD thanks guys :D
1612658578
GiGs
Pro
Sheet Author
API Scripter
With change events (not click events), upper case letters there sometimes work - they shouldn't ever work, according to the documentation, but sometimes they do. It's erratic, so it's best to make sure you always change to lower case. But click events follow the documentation much more strictly, and upper case letters will always cause the sheet worker to fail.