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

Elegant way to change text color when an hidden flag is triggered

1598648974
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
Is there a way (without using DOM) to write a function that changes the color of an input if an hidden flag is triggered. The only way I can think about is using something similar to what we do with TABS right now: create two div containing the same attributes, one with text color red and one with text color black. When the flag is activated you hide one input and show the other. This works, but I was curious if it was possible to change the color using a sheet worker
1598650388

Edited 1598650420
Finderski
Pro
Sheet Author
Compendium Curator
You can do it with CSS, no need to hidden tabs/divs or JS.  Just a couple of classes and a hidden input. :) If you give us more details, we can provide more detailed help, but what you want is possible without too much effort.
1598657791
Andreas J.
Forum Champion
Sheet Author
Translator
What finderski said. On a related note, DOM is basicly inaccessible in character sheets, we only have limited access to sheet attribute values & changes.
1598658172
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
Hi Andreas,  yeah that's why I asked it without DOM :/ Thanks Finderski, at the end I choose another approach (not involving color) but I might try to put some code here soon so at least it might be useful if someone else has a similar problem (and if my code does not work, hopefully someone in the community might be able to fix it and give a template to other)
1598708568
Andreas J.
Forum Champion
Sheet Author
Translator
You still didn't explain what effect you want, or why. The method your trying to apply for what you want to happen might have better ways to do it, but we can't help you until you tell the core thing it's supposed to do.
1598839948
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
You are right, basically i have some properties that need to be initialized  based on the initial attributes when you create a new pc (Initial SAN, breaking point, max wp, initial WP),  after the character is created any further change on those attributes will only change the max WP and none of the other properties. To do so i had used an hidden flag that is triggered once the attributes are changed by the user for the first time.  I had 3 options for doing it 1) i make the hidden flag non hidden (through a toggle) and i hope that the players remember to trigger it when they start the game 2) i let all the attributes empty so that thr player is forced to fill them at least once 3) Since it's incredibly rare that a player would manage to finish a scenario without losing SAN,HP, and WP., i would initialize at character creation the values of tge attributes to their default value (10), and the flag will be trigger the first time the player change the Attributes or the first time they change the initial SAN, WP or HP. The change of color was for option 3 to give the player a visual reminder: the color of WP, HP, SAN would have been red until you either set the attributes or you modify the initial values of SAN, WP, HP. (This is why i needed to change color to the input) Option 1 would have been nice to implement but it would have ruined the design of the sheet so i discarded it (moreover it would have meant makinf a one time button that wasn't really necessary). Option 3 had several advantages but there were limit cases (homescenes and ritual) that would have make it risky to implement. In the end i went with option 2 that was the simplest one but requires a bit more work from the player. 
1598882842

Edited 1598882932
Caden
Forum Champion
Sheet Author
API Scripter
Compendium Curator
For performance, I'd use a sheetworker to update my flag but that really depends on what you're trying to do. Basically you want something like this: HTML <input type='hidden' name='attr_flag' value='on' /> <div class='highlight'>Text</div> CSS input[value='on'] + div.sheet-highlight {      color : red ;   }
1598886446
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
ooooh that's neat way simpler than what I would have used. Thanks :D