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 .
×

Regards to hiding options on a custom character sheet.

1621552854

Edited 1621552882
I'm currently in the process of making a custom character sheet at the moment, and I'm trying to have it so that if you have a checkbox input selected it adds an option to a select element. How would I go about doing that?
1621558129
Finderski
Pro
Sheet Author
Compendium Curator
It depends on your code structure. But the high-level is, hide that option (via display: none) and then when the check box it checked, you'd unhide the option via something like display:inline. Example HTML: <input type="checkbox" name="attr_myCheck" class="sheet-showThing"> <select name="attr_mySelect" class="sheet-thing"> <option class="sheet-hideThenShow" value="1">1</option> <option value="2">2</option> </select> CSS: .sheet-hideThenShow { display:none; } .sheet-showThing:checked ~ .sheet-thing .sheet-hideThenShow { display: inline; }
Thanks, I wasn't entirely sure I could do that to an option, I'll give it a shot.
As a side note, since I don't want to make a new thread for it. I'm currently having an issue with a sheetworker. I'm trying to have it for a toggleable button, but something about it is breaking and not toggling. HTML <input type="hidden" class=sheet-toggletest name="attr_toggletest" value="1"> Toggle Test: <span class=sheet-buttontest>Test</span> <button type="action" name="act_toggle">Testing</button> css .sheet-buttontest{     display: none; } .sheet-toggletest[value="1"] ~ div.sheet-buttontest{ display:block; } sheetworker on('clicked:toggle',function() {     getAttrs(["toggletest"],(value) => {         setAttrs({     toggletest: (value.toggletest+1)%2 });     }); });
1621590127
Finderski
Pro
Sheet Author
Compendium Curator
For the sheet worker issue, try using parseInt...the value is going to be a string by default. on('clicked:toggle',function() {     getAttrs(["toggletest"],(value) => { let togglevalue = parseInt(value.toggletest) || 0;         setAttrs({     toggletest: (togglevalue+1)%2 });     }); });
1621592558
Finderski
Pro
Sheet Author
Compendium Curator
Kisato R. said: Thanks, I wasn't entirely sure I could do that to an option, I'll give it a shot. If this doesn't work (I honestly can't remember if it does or not) you also create a fake drop down using radio buttons, but it's a bit involved CSS-wise. If you need it, I'll see if I can dig up an example...
1621622635
Andreas J.
Forum Champion
Sheet Author
Translator
Suggest you check out the couple of example on the wiki for show/hide/switch visible areas on sheets: <a href="https://wiki.roll20.net/CSS_Wizardry#Show.2FHide_Areas" rel="nofollow">https://wiki.roll20.net/CSS_Wizardry#Show.2FHide_Areas</a>
Finderski said: For the sheet worker issue, try using parseInt...the value is going to be a string by default. on('clicked:toggle',function() { &nbsp;&nbsp;&nbsp;&nbsp;getAttrs(["toggletest"],(value) =&gt; { let togglevalue = parseInt(value.toggletest) || 0; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttrs({ &nbsp;&nbsp;&nbsp;&nbsp;toggletest: (togglevalue+1)%2 }); &nbsp;&nbsp;&nbsp;&nbsp;}); }); I'm assuming that I've botched something up, because the text isn't appearing
Note to self, the span element does not like that
My next step is to put it into a repeating section, and that comes with its own lovely jank. &lt;fieldset class="repeating_equip"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;button type="action" name="act_equipsetting"&gt;&lt;/button&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="hidden" class="sheet-equipmenttoggle" name="attr_equipmentsettings"&nbsp; value="0"&nbsp; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="sheet-equipmentsettings"&gt; &nbsp;&nbsp;&nbsp;&nbsp;Text &nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt; &lt;/fieldset&gt; the css is set like I would if I were doing it like a normal div. And the sheetworker is at it's core the same, however on("clicked:repeating_equip:equipmentsetting", function() { &nbsp;&nbsp;&nbsp;&nbsp;getAttrs(["repeating_equip_equipmentsetting"],(v) =&gt;{ &nbsp;&nbsp;&nbsp;&nbsp;let setting = console.log(parseInt(v.equipmentsetting]) || 0); setAttrs({ &nbsp;&nbsp;&nbsp;&nbsp;repeating_equip_equipmentsetting: (setting+1)%2; }); }); }); but the event instance has been update so its&nbsp; change:repeating_equip:equipmentsetting &nbsp; and then&nbsp; repeating_equip_equipmentsetting as it says on the&nbsp; Repeating Sections Wiki Is this a quirk with how the getAttr works where it's incompatible with clicked. The lack of debugging tools makes it a little hard to diagnose.