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

Read non repeating attribute in repeating fieldset

1610745255
Jiboux
Pro
Sheet Author
Compendium Curator
Hi, Pretty straightforward question. I have a repeating section for skills in the character sheet I am working on, and I would like to have a toggle OUT of the fieldset to get to edit mode, which would unhide some fields and make some others editable... I have a class that works well where depending on the status of a checkbox of the class TestChecked, everything of the class HideIfChecked disappears, and it is done so that the testChecked can be in the parent. .sheet-testChecked:checked~.sheet-HideIfChecked{display:none;} But : -the  testChecked is able to inherit to children, : the code below works just fine <input class="testchecked" type="checkbox" name="attr_test"> <div> <span> this text is always on</span> <span class= "HideIfChecked"> This text depend on the checkbox</span> </div> -It doesn't seem to be able to inherit within the fieldset. The code below doesn't work as intended <input class="testchecked" type="checkbox" name="attr_test"> <div> <fieldset><span> this text is always on</span> <span class= "HideIfChecked"> This text depend on the checkbox</span> </fieldset></div> -When I have no choice than to have the checkbox out of the inherit line, I just put a second one with the same attr_name so I tried the code below... But the attr_test in the fieldset is not the attr_test of out of the fieldset <input class="testchecked" type="checkbox" name="attr_test"> <div> <fieldset> <input class="testchecked" hidden type="checkbox" name="attr_test"> <span> this text is always on</span> <span class= "HideIfChecked"> This text depend on the checkbox</span> </fieldset></div> Any idea how I could cross the fieldset line OR test the global attribute within the fieldset ?
1610766245

Edited 1610766261
GiGs
Pro
Sheet Author
API Scripter
Attribute names inside a fieldset get changed, to something like fieldsetname_-GHETCJRG7THLKH7_attribute_name Remember a fieldset is repeating section: it can have anything from 0 to a 100 (or more!) rows, and every row has a copy of the same code. So roll20 needs a way to know which row you are referring to when you access an attribute - hence all attributes in a repeating section get transformed into a longer name uniquely identifying their place in the sheet. So you'd need to use a sheet worker to check for changes in the outside attribute, and apply them to the above attribute on all rows of the fieldset using getSectionIDs. Something like: on ( 'change:test' , ()  =>  {      getAttrs ([ 'test' ],  values   =>  {          getSectionIDs ( 'reapeating_fieldset-name' ,  idarray   => {              const   output  = {};              const   test  =  values . test ;              idarray . forEach ( id   =>  {                  output [ `fieldset-name_ ${ id } _test` ] =  test ;             });              setAttrs ( output );         });     }); }); Note that I've assumed the attribute name istest. If its different do a find/replace to change it to whatever it actually is. likewise I've uses "fieldset-name" as your fieldset name-  you'll need to change that to match the real fieldset name.,
1610816372
Jiboux
Pro
Sheet Author
Compendium Curator
Thanks Again. Somehow the code I was starting with had already this case, and dealt with it in CSS... It kept the common attribute out of the fieldset, but had a style with the ~.repcontainer that allowed the style to cascade
1610849737
GiGs
Pro
Sheet Author
API Scripter
That makes sense. For fieldsets, the html on a character sheet when used is different from the sheet in design - the fieldset is like a blueprint, it tells roll20 what to build. Roll20 then adds a repcontainer class and repitem classes for each row. Because of this, getting pure CSS solutions to work with fieldsets sometimes needs to extra knowledge about how the sheet is actually laid out.