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

How can I apply textworker code in multiple places?

I have a &lt;table&gt; tag with many &lt;td&gt; tags. The code below works fine when applied to one &lt;td&gt;tag. (I want different css code to be applied to &lt;td&gt;tags depending on select option!!) text worker on('change:maptile_5a', () =&gt; { getAttrs(['maptile_5a'], v =&gt; { const modifier = v.maptile_5a; setAttrs({ mod_maptile_5a: modifier }); }); }); I found this link and modified it in several suggested ways. But it doesn't work.&nbsp; <a href="https://wiki.roll20.net/UniversalSheetWorkers" rel="nofollow">https://wiki.roll20.net/UniversalSheetWorkers</a> Here is my code.... text worker const maptds =['maptile_5a','maptile_5b','maptile_5c','maptile_5d','maptile_5e','maptile_5f','maptile_5g', 'maptile_5h','maptile_5i','maptile_5j','maptile_5k','maptile_5l', 'maptile_5m','maptile_5n','maptile_5o']; maptds.forEach(stat =&gt; { on('change:${stat} sheet:opened', () =&gt;{ getAttrs([stat], values =&gt;{ const modifier = values[stat]; setAttrs({ ['mod_${stat}']:modifier }); }); }); }); Here is my html code&nbsp; HTML &lt;input type="hidden" class ="maptile" name="attr_mod_maptile_5a" value="none"&gt; &lt;td class="col_a"&gt; &lt;select class = "drawmap" name="attr_maptile_5a"&gt; &lt;option value ="none" selected&gt;none&lt;/option&gt; &lt;option value="underground"&gt;underground&lt;/option&gt; &lt;option value="fire"&gt;fire&lt;/option&gt; &lt;option value="smoke"&gt;smoke&lt;/option&gt; &lt;option value="lightdarkness"&gt;lightdarkness&lt;/option&gt; &lt;option value="darkness"&gt;darkness&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;input type="hidden" class ="maptile" name="attr_mod_maptile_5b" value="none"&gt; &lt;td class="col_b"&gt; &lt;select class = "drawmap" name="attr_maptile_5b"&gt; &lt;option value ="none" selected&gt;none&lt;/option&gt; &lt;option value="underground"&gt;underground&lt;/option&gt; &lt;option value="fire"&gt;fire&lt;/option&gt; &lt;option value="smoke"&gt;smoke&lt;/option&gt; &lt;option value="lightdarkness"&gt;lightdarkness&lt;/option&gt; &lt;option value="darkness"&gt;darkness&lt;/option&gt; &lt;/select&gt; &lt;/td&gt;
1664475648
GiGs
Pro
Sheet Author
API Scripter
I can't see exactly what you;re doing, but you can't dynamically change the CSS that applies to code. CSS is fixed. But you can change which CSS set is active - choose which gets displayed based on your sheet worker. Personally I'd advise moving away from tables and using CSS Grid insteda - its easier to code, and has the advantage that it wont be summarily rejected by the roll20 team the way tables are. It's probably not related to your issue, but is worth doing: <a href="https://cybersphere.me/css-grid/" rel="nofollow">https://cybersphere.me/css-grid/</a> <a href="https://cybersphere.me/dont-use-table-use-grid/" rel="nofollow">https://cybersphere.me/dont-use-table-use-grid/</a>
1664499626

Edited 1664499829
Here is my CSS code .charsheet input[value="none"] + td { &nbsp; &nbsp; background: none; &nbsp; &nbsp; border: 1px dashed black; } .charsheet input[value="underground"] + td{ &nbsp; &nbsp; background-color: rgba(75, 49, 10, 0.5); } .charsheet input[value="fire"] + td{ &nbsp; &nbsp; background-color: rgba(255, 38, 0, 0.5); } .charsheet input[value="smoke"] + td{ &nbsp; &nbsp; background-color: #c7c7c783 } .charsheet input[value="lightdarkness"] + td{ &nbsp; &nbsp; background-color: rgba(51, 51, 51, 0.5); } .charsheet input[value="darkness"] + td{&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; background-color: rgba(0, 0, 0, 0.8); } Here is my test screen shot. But I have 101 different &lt;td&gt; tags. To apply my first textworker code, I have to write 102 almost identical textworker codes. Umm...
1664502034

Edited 1664502157
GiGs
Pro
Sheet Author
API Scripter
So you want those grids to take the colour from that dropdown? If I'm following what you're doing, you can get rid of the sheet worker and change this: &lt;input type="hidden" class ="maptile" name="attr_mod_maptile_5a" value="none"&gt; to &lt;input type="hidden" class ="maptile" name="attr_maptile_5a" value="none"&gt; It looks like your CSS is built correctly, but I'd have to see the full sheet HTML and CSS (post in pastebin.com if inclined) to see why it isnt working, if it isnt working after the above change. PS: I wrote that UniversalSheetWorker page, and you can do just one sheet worker instead of 102, but in this case it looks like you don't need that - just find and replace attr_mod_map to attr_map.
This seems to be the best answer. Thx!!!!&nbsp;have a good day!