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

Npc/PC button

1508724266
Pat S.
Forum Champion
Sheet Author
On my sheet I have a button that has an npc section to appear when it is clicked but what I want is for the rest of the sheet (the pc sheet) to disappear. Anyone know of threads that discuss this? I'm almost going to go digging through various sheets to look over their codes for ideas, any suggestions there?
1508731191

Edited 1508731296
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I've got a few sections of my sheet that operate on this principle. At its core, I use a radio button for the toggle. If the radio button for the PC sheet is checked, the PC sheet is displayed, if the radio sheet for the NPC sheet is checked, the NPC sheet is displayed. To get around the problem with duplicates of radio buttons not working, I use sheetworkers to pass the value of the attribute that the user actually interacts with (say an NPC checkbox) to the radio buttons which I have hidden in my container to control the display of the relevant elements.
1508735329

Edited 1508735368
vÍnce
Pro
Sheet Author
Here's something I've modified a little (...original code borrowed stolen from CPP  here  on the css wizardry thread) <!--HTML--> <input type="checkbox" name="attr_switch" class="sheet-block_switch" value="1"><span></span><span></span> <br> <div class="sheet-block_a"> PC Stuff </div> <div class="sheet-block_b"> NPC Stuff </div> <!--CSS--> div.sheet-block_a {     display: inline; } div.sheet-block_b {     display: none; } input.sheet-block_switch {     opacity: 0;     width:4em;     position:fixed; } input.sheet-block_switch:checked ~ div.sheet-block_a {     display: none; } input.sheet-block_switch:checked ~ div.sheet-block_b {     display: inline; } input.sheet-block_switch:not(:checked) ~ span:after {     content:" PC";     font-weight:bold; } input.sheet-block_switch:not(:checked) ~ span + span:after {     content:"/NPC";     font-weight:normal; } input.sheet-block_switch:checked ~ span:after {     content:" PC";     font-weight:normal; } input.sheet-block_switch:checked ~ span + span:after {     content:"/NPC";     font-weight:bold; }
1508756089
Pat S.
Forum Champion
Sheet Author
Sweet. Thanks for the info and coding. The next chance I get I'm going to start breaking my sheet so I can get it working better.