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

Variable "Select" for Alignment and Deity

Greetings. I have a Select for Alignment as follows: <select class="sheet-input-large" name="attr_Alignment" value="" title="@{Alignment}"> <option>Select</option> <option>Chaotic Evil</option> <option>Chaotic Good</option> <option>Chaotic Neutral</option> <option>Lawful Evil</option> <option>Lawful Good</option> <option>Lawful Neutral</option> <option>Neutral Evil</option> <option>Neutral Good</option> <option>Neutral</option> </select> I have another Select with a list of Dieties. How can I present Deity options based on the Alignment selection rather than just showing ALL deities? Thanks in advance.
1641617765
Finderski
Pro
Sheet Author
Compendium Curator
There are several ways to accomplish this, but probably the most basic would be to use a hidden field of the alignment to help control what options are displayed in the Deity drop down. It looks like this: html <select name="attr_alignment"> <option value="good" selected>Good</option> <option value="neutral">Neutral</option> <option value="evil">Evil</option> </select> <input type="hidden" class="alignment" name="attr_alignment" value="good" /> <select name="attr_deity"> <option class="good neutral evil" value="none">Select a Deity</option> <option class="good neutral" value="Balfor">Good Neutral</option> <option class="good" value="Buren">Good</option> <option class="evil" value="Blinken">Evil</option> <option class="neutral" value="neutral">Neutral</option> <option class="neutral evil" value="neutral Evil">Neutral Evil</option> </select> CSS (not using legacy Sanitization): .alignment[value="good"] ~ select > option:not([class~="good"]) { display: none; } .alignment[value="neutral"] ~ select > option:not([class~="neutral"]) { display: none; } .alignment[value="evil"] ~ select > option:not([class~="evil"]) { display: none; } That method isn't perfect, for example, it won't hide an option that's selected, so if the character started with the alignment of Good, and then had it changed to Evil, selecting Evil in the Alignment wouldn't unselect or hide the option of the currently selected Good deity, but once they click on the drop down the good deity would be hidden.  
1641623804
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Finderski's got a great solution. Add some sheetworker validation in there, and you can even solve the issue of not hiding the selected option that he mentioned by changing the selection if it is no longer valid.
Thanks guys, I'll try it out. Cheers