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

Need some help checkbox checked to display a div

1537465130
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
I am making a sheet configuration box. It has check boxes in it when checked are supposed to display a section in another tab on the character sheet. my HTML and CSS: The area that I am displaying with a checked checkbox: <div class="sheet-groundmove"> <div>        "bunch of content here" </div> </div> The checkbox itself: <input type="checkbox" class="sheet-boolean" name="attr_groundmove"/> The CSS: div.sheet-groundmove { display:none; } input.sheet-boolean[type="checkbox"][name="attr_groundmove"]:checked ~ div.sheet-groundmove { display:inline-block; } Can anyone tell me what I have wrong here and what it is supposed to look like?
1537470596

Edited 1537470689
GiGs
Pro
Sheet Author
API Scripter
You cant use name like that in the css.&nbsp; The CSS wizardry wiki page shows one way to do it here:&nbsp; <a href="https://wiki.roll20.net/CSS_Wizardry#Hide_Areas" rel="nofollow">https://wiki.roll20.net/CSS_Wizardry#Hide_Areas</a> The checkbox is the same: &lt;input type="checkbox" class="sheet-boolean" name="attr_groundmove"/&gt; The CSS is altered: div.sheet-groundmove { display:none; } input.sheet-boolean:checked ~ div.sheet-groundmove { display:inline-block; } But with this approach, you might need the checkbox and the div it affects to be in the same tab. (I'm not sure.) I personally use a slightly different approach.&nbsp; The checkbox has a linked hidden input, like so: &lt;input type="checkbox" class="whatever" name="attr_groundmove" value="1"/&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_groundmove" /&gt; And then the CSS only needs one entry: input.sheet-boolean:not([value='1']) ~ div.sheet-groundmove { &nbsp; display: none; } With this approach you can put the hidden input anywhere in the sheet. i normally have a bunch of them at the start of the sheet, the config options. I'd also suggest changing the stylename sheet-boolean, to something like sheet-groundmove-boolean, just in case you want to use this&nbsp; technique multiple times in the same sheet - they'll each need their own distinct name.&nbsp;
1537550385
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Just a bit of confusion here. Where are we placing the checkboxes?
1537550944
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Wait! I have it working....Thanks
1537551742

Edited 1537551777
GiGs
Pro
Sheet Author
API Scripter
Edit: since you have it working, ignore this :) Ah I forgot you have them in different tabs. Try using the second method I suggested. Have your checkbox and div as they are. Move the hidden input to the very top of your character sheet's html &lt;input type="hidden" class="sheet-boolean" name="attr_groundmove" /&gt; In your CSS, use this input.sheet-boolean:not([value='1']) ~ div .sheet-groundmove { &nbsp; display: none; } Note the space between div and .sheet. See if that works.
1537557037

Edited 1537557822
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
edit: Somehow I broke when I added more. So if I have more than one of these type switches can I do this? &lt;input type="hidden" class="sheet-boolean" name="attr_groundmove" /&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_watermove" /&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_airmove" /&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_spacemove" /&gt; At the top of the sheet. with these on an options tab &lt;input type="checkbox" class="sheet-boolean" name="attr_groundmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_watermove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_airmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_spacemove" value="1"/&gt; and this in CSS: input.sheet-boolean:not([value='1']) ~ div .sheet-moveoption { display: none; }
1537558138

Edited 1537558250
GiGs
Pro
Sheet Author
API Scripter
You want to give each one its own class - dont use sheet-boolean for all of them. It's an identifier for that specific checkbox. So, sheet-boolean-groundmove for the first, sheet-boolean-watermove for the second, and so on. (each linked checkbox and hidden input should have the same class, and no other pair should have the same class). Then&nbsp; input.sheet-boolean-groundmove:not([value='1']) ~ div .sheet-moveoption { display: none; }
1537558201
Finderski
Plus
Sheet Author
Compendium Curator
Scott S. said: edit: Somehow I broke when I added more. So if I have more than one of these type switches can I do this? &lt;input type="hidden" class="sheet-boolean" name="attr_groundmove" /&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_watermove" /&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_airmove" /&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_spacemove" /&gt; At the top of the sheet. with these on an options tab &lt;input type="checkbox" class="sheet-boolean" name="attr_groundmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_watermove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_airmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_spacemove" value="1"/&gt; and this in CSS: input.sheet-boolean:not([value='1']) ~ div .sheet-moveoption { display: none; } I find it easier just to give each checkbox a different class. That way you can use the class:checked &nbsp;method. &nbsp;If you like the sheet-boolean for a styling purpose it can have to different classes.
1537559052
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Whats the class:checked &nbsp;method and will it work on divs that are on another tab?
1537561136

Edited 1537561192
Finderski
Plus
Sheet Author
Compendium Curator
Scott S. said: Whats the class:checked &nbsp;method and will it work on divs that are on another tab? Sorry... &lt;input type="checkbox" class="sheet-boolean sheet-ground" name="attr_groundmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean sheet-water" name="attr_watermove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean sheet-air" name="attr_airmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean sheet-space" name="attr_spacemove" value="1"/&gt; .sheet-ground:not(:checked) ~ div .sheet-moveoption { display: none; }
1537561406
Finderski
Plus
Sheet Author
Compendium Curator
Also, looking at the above code, I think the issue is that everyone of the inputs had the same value and the same class, so if one wasn't checked, they'd all stay hidden, because the rule would be true. &nbsp;If you wanted to keep with the value check, just give each input a different value (e.g. 1-4). &nbsp;At least, I think that would &nbsp;work. I just find it easier to give each input it's own class...easier to follow the logic that way, too.
1537562345
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
I cannot get one to work at all now....somehow I really broke it
1537562799
Finderski
Plus
Sheet Author
Compendium Curator
Can you post a barebones version? Meaning showing the inputs and tabs and the CSS?
1537563290
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
CSS: input.sheet-ground:not(:checked) ~ div .sheet-moveoption { display: none; } Options tab: &lt;input type="checkbox" class="sheet-boolean sheet-ground" name="attr_groundmove" value="1"/&gt; General tab: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type="checkbox" class="sheet-boolean sheet-ground" name="attr_groundmove" value="1"/&gt; &lt;div class="sheet-moveoption"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&lt;div class="sheet-row"&gt; &lt;!-- Unhide this when checkbox is checked --&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bunch of content here &lt;!-- Unhide this when checkbox is checked --&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt; &lt;!-- .sheet-row --&gt; &lt;!-- Unhide this when checkbox is checked --&gt; &lt;/div&gt;
1537580286
Finderski
Plus
Sheet Author
Compendium Curator
Try this for your CSS: .sheet-ground:not(:checked) ~ .sheet-moveoption { display: none; } You could even do this: .sheet-ground:not(:checked) + .sheet-moveoption { display: none; }
1537708019

Edited 1537708088
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
OK so the battle continues.... The divs are displaying on check. However they are not independent of each other. Instead they cascade down when checked. The problem I ran into arose when I changed the checkbox classes from sheet-boolean to anything other than that. HTML: &lt;div class="sheet-row sheet-row-stats"&gt; &lt;div class="sheet-cell sheet-col0"&gt;&lt;input type="checkbox" class="sheet-boolean ground" name="attr_groundmove" value="1"/&gt;&lt;/div&gt;&lt;div class="sheet-cell sheet-col1"&gt;&lt;span class="sheet-popup"&gt;Ground Movement Mode.&lt;/span&gt;&lt;span class="sheet-tooltip"&gt;Only used when character&lt;br /&gt;is aquatic or amphibious.&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="sheet-row sheet-row-stats"&gt; &lt;div class="sheet-cell sheet-col0"&gt;&lt;input type="checkbox" class="sheet-boolean" name="attr_wateroption" value="1"/&gt;&lt;/div&gt;&lt;div class="sheet-cell sheet-col1"&gt;&lt;span class="sheet-popup"&gt;Water Movement Mode.&lt;/span&gt;&lt;span class="sheet-tooltip"&gt;Water Move: Normally Basic Move/5, rounded down.&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_wateroption" /&gt; &lt;div class="sheet-moveopton"&gt; &lt;div class="sheet-row sheet-row-stats"&gt; &lt;div class="sheet-cell sheet-col0"&gt;&lt;input type="checkbox" class="sheet-boolean" name="attr_aquaticoption" value="1"/&gt;&lt;/div&gt;&lt;div class="sheet-cell sheet-col2"&gt;&lt;span class="sheet-popup"&gt;Aquatic&lt;/span&gt;&lt;span class="sheet-tooltip"&gt;Amphibious: both water and ground Move equal Basic Move.&lt;/span&gt;&lt;/div&gt; &lt;div class="sheet-cell sheet-col0"&gt;&lt;input type="checkbox" class="sheet-boolean" name="attr_amphiboption" value="1"/&gt;&lt;/div&gt;&lt;div class="sheet-cell sheet-col2"&gt;&lt;span class="sheet-popup"&gt;Amphibious&lt;/span&gt;&lt;span class="sheet-tooltip"&gt;Amphibious: both water and ground Move equal Basic Move.&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="sheet-row sheet-row-stats"&gt; &lt;div class="sheet-cell sheet-col0"&gt;&lt;input type="checkbox" class="sheet-boolean" name="attr_airoption" value="3"/&gt;&lt;/div&gt;&lt;div class="sheet-cell sheet-col1"&gt;&lt;span class="sheet-popup"&gt;Air Movement Mode.&lt;/span&gt;&lt;span class="sheet-tooltip"&gt;Only used when character&lt;br /&gt;is aquatic or amphibious.&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="sheet-row sheet-row-stats"&gt; &lt;div class="sheet-cell sheet-col0"&gt;&lt;input type="checkbox" class="sheet-boolean" name="attr_spaceoption" value="4"/&gt;&lt;/div&gt;&lt;div class="sheet-cell sheet-col1"&gt;&lt;span class="sheet-popup"&gt;Space Movement Mode.&lt;/span&gt;&lt;span class="sheet-tooltip"&gt;Only used when character&lt;br /&gt;has an airmove&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; CSS: input.sheet-boolean:not([value='1']) ~ div.sheet-groundmove { &nbsp; display: none; } input.sheet-boolean:not([value='1']) ~ div.sheet-watermove { &nbsp; display: none; } input.sheet-boolean:not([value='1']) ~ div.sheet-airmove { &nbsp; display: none; } input.sheet-boolean:not([value='1']) ~ div.sheet-spacemove { &nbsp; display: none; }
1537713430
GiGs
Pro
Sheet Author
API Scripter
You cannot have them all with the same class (sheet-boolean), and the same value (value=1). This absolutely will not work . Can you post the code you attempted with different class names?
1537714258
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
input.sheet-boolean .sheet-groundoption:not([value='1']) ~ div.sheet-groundmove { display: none; } input.sheet-boolean .sheet-wateroption:not([value='1']) ~ div.sheet-watermove { display: none; } input.sheet-boolean .sheet-airoption:not([value='1']) ~ div.sheet-airmove { display: none; } input.sheet-boolean .sheet-spaceoption:not([value='1']) ~ div.sheet-spacemove { display: none; } &lt;input type="checkbox" class="sheet-boolean sheet-groundoption" name="attr_groundmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean sheet-wateroption" name="attr_watermove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean sheet-airoption" name="attr_airmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean sheet-spaceoption" name="attr_spacemove" value="1"/&gt; &lt;input type="hidden" class="sheet-boolean" name="attr_groundoption" /&gt; &lt;div class="sheet-groundmove"&gt;.... &lt;input type="hidden" class="sheet-boolean" name="attr_wateroption" /&gt; &lt;div class="sheet-watermove"&gt;...
1537720753
GiGs
Pro
Sheet Author
API Scripter
Its the class of the hidden input that this method depends on, so change&nbsp; the above to: input type="checkbox" class="sheet-boolean" name="attr_groundmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_watermove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_airmove" value="1"/&gt; &lt;input type="checkbox" class="sheet-boolean" name="attr_spacemove" value="1"/&gt; The sheet-boolean class above is used purely for styling the checkboxes appearance, its not part of the process for displaying or hiding the div. The inputs and divs should be something like: &lt;input type="hidden" class="sheet-groundoption" name="attr_groundoption" /&gt; &lt;div class="sheet-groundmove"&gt;.... &lt;input type="hidden" class="sheet-wateroption" name="attr_wateroption" /&gt; &lt;div class="sheet-watermove"&gt;... &lt;input type="hidden" class="sheet-wateroption" name="attr_airoption" /&gt; &lt;div class="sheet-airmove"&gt;... &lt;input type="hidden" class="sheet-wateroption" name="attr_spaceoption" /&gt; &lt;div class="sheet-spacemove"&gt;...
1537727134
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
So the CSS is staying like this? input.sheet-boolean .sheet-groundoption:not([value='1']) ~ div.sheet-groundmove { display: none; }
1537727278
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
or is it this? input.sheet-groundoption:not([value='1']) ~ div.sheet-groundmove { display: none; }
1537728642
GiGs
Pro
Sheet Author
API Scripter
Oh good catch, I didnt notice the sheet boolean in the css. The last one: input.sheet-groundoption:not([value='1']) ~ div.sheet-groundmove { display: none; }
1537728936
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Well it is working from another tab even. Thank you so much for your help.
1537729157
GiGs
Pro
Sheet Author
API Scripter
You're welcome :)&nbsp;
1537797928

Edited 1537797963
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
To everyone that is looking at this thread. What I have accomplished with G G's help is setting up an options box on one tab that reveals entries on another tab in the character sheet. This will allow the character sheet to be configurable, in this case, for different modes on movement by checking boxes on the options tab of this character sheet. A key thing I learned here is that the visible checkbox is linked by "name" to a hidden checkbox and that is linked by CSS to the div class that I am revealing/hiding. I believe it will be possible to also do this with radio buttons later as I attempt to set-up a hit location box that will have differing configurations based upon the body type such as bi-pedal, quadruped, and so-on. On the sheetworker side I plan to reflect this as well for combat automation. Again many thanks to G G and Finderski &nbsp;for taking time out to help me get this done. I hope that my efforts on the GURPS character sheet will aid GM's and players on Roll20.
1537805912

Edited 1537809759
GiGs
Pro
Sheet Author
API Scripter
You can do the same kind of thing with select/radio buttons, the hidden input gets its value from the selected radio button, and the CSS uses the value of the hidden input in the same way. You'll have different values like input.sheet-options:not([value='1']) ~ div.sheet-groundmove { display: none; } input.sheet-options:not([value='2']) ~ div.sheet-groundmove { display: none; } and so on.
1537807078
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
That's kinda what I figured
1537809837
GiGs
Pro
Sheet Author
API Scripter
Oops, had an error in my example code. Its fixed above. It's meant to be an example of how you can have the same class (there's only one hidden input, and you use its class), as long as you check for different values in the input.
1537810328
SᵃᵛᵃǤᵉ
Sheet Author
API Scripter
Here's a spin on the above...your thoughts? input.sheet-current:([value='0']) ~ div.sheet-none { color:red;} input.sheet-current:([value='1']) ~ div.sheet-light { color:red;} input.sheet-current:([value='2']) ~ div.sheet-med { color:red;} input.sheet-current:([value='3']) ~ div.sheet-hvy { color:red;} input.sheet-current:([value='4']) ~ div.sheet-xhvy { color:red;} input.sheet-current:([value='5']) ~ div.sheet-max { color:red;} Input is based on a sheetworker that sets the "attr_encumbrance_level" a hidden input. The idea is to turn the column of the encumbrance table for that load red.