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

[Sheet Workers] All these radio buttons/checkboxes to match that single radio button/checkboxe

In my Cthulhu-tech sheet, I have a lot of checkboxes linked to appearing and disappearing sections (swapping things out on the CSS Wizardry page).  Right now, I am using a bunch of hidden checkboxes with matching names* so a whole bunch of sections change all at once .  This...hangs, from time to time.  So I wanted to put sheet workers on it, but I am having a hard time.  Can anyone help? Mostly, I want to be able to change the check'ed status of a lot of checkboxes based on the check'ed status of the a single checkbox.   * this was definitely NOT from the Savage World Tabbed sheet, because I would never coding from anyone
For clarification: Here is the master switch (a radio button): <div class="sheet-form">     <input type="radio" class="sheet-form sheet-man" name="attr_form_switch" value="0" checked />     <input type="radio" class="sheet-form sheet-monster" name="attr_form_switch" value="1"/>         <span class="sheet-form sheet-man">Mortal</span>         <span class="sheet-form sheet-monster">Tager</span> </div> Here are the hidden checkboxes: <input type="checkbox" class="sheet-tager_human sheet-hidden" name="attr_form_switch" value="1"/><span></span> And here is the latest thing I have been trying to manhandle into triggering the checkboxes: on("form_switch", function() {         getAttrs(["form_switch"], function(values) {       if (value.form_switch = 0) {       setAttrs({form_switch: 1});       }       else if (value.form_switch = 1) {           setAttrs({form_switch: 0});       }     }); });
1457134970

Edited 1457135072
Wes
Pro
Sheet Author
Hey CPP, I'm new to this whole thing and I'm sure our lovely helpful friends will come by and point out my mistakes but I have this for doing what I think you are trying to accomplish. I believe that that js is changing its own value. You probably want something like: on("form_switch", function() {         getAttrs(["form_switch"], function(values) {       if (value.form_switch = 0) {       setAttrs({form_switch _tager : 1});       }       else if (value.form_switch = 1) {           setAttrs({form_switch _tager : 0});       }     }); }); and change the attr name of the hidden checkbox to attr_form_switch_tager.
1457174878
Finderski
Plus
Sheet Author
Compendium Curator
Coal Powered Puppet said: For clarification: Here is the master switch (a radio button): <div class="sheet-form">     <input type="radio" class="sheet-form sheet-man" name="attr_form_switch" value="0" checked />     <input type="radio" class="sheet-form sheet-monster" name="attr_form_switch" value="1"/>         <span class="sheet-form sheet-man">Mortal</span>         <span class="sheet-form sheet-monster">Tager</span> </div> Here are the hidden checkboxes: <input type="checkbox" class="sheet-tager_human sheet-hidden" name="attr_form_switch" value="1"/><span></span> And here is the latest thing I have been trying to manhandle into triggering the checkboxes: on(" change: form_switch", function() {         getAttrs(["form_switch"], function(values) {       if (value.form_switch = 0) {       setAttrs({form_switch: 1});       }       else if (value.form_switch = 1) {           setAttrs({form_switch: 0});       }     }); }); You're missing the "change" in that code (see above bolded change). I also agree with Wes, that unless you change the names of the checkboxes, you'll still run into the same issue you are now, where checking one checks them all (even without the sheet worker). And really (and I could be wrong), it would be better to have each checkbox have a different name, otherwise it's only slightly different from what you have now and sheet worker isn't saving you much. I hope that makes sense. And this is a good idea that I may have to look at cribbing... ;)
The intent was to slave a bunch of check boxes to a single radio button, so if the radio button is pushed, all of the checkboxes are checked The radio button is a cycling image, from the Css Wizardry (human form/monster form) The hidden checkboxes are swapping, "show-this-not-that/show-that-not-this" from the same thread. So, as defualt, the human parts of the sheet are shown.  When the radio button is clicked, the monster form is shown. Is there a way to apply a checked status through sheet workers?  Or should I use some kind of css for this?
1457464827

Edited 1457465043
chris b.
Pro
Sheet Author
API Scripter
It would be easier if you gave the checkboxes different attribute names, since then you could set them, since in the code above it looks like you're just setting an infinite loop. if you have hidden checkboxes <input type="checkbox" class="sheet-tager_human sheet-hidden" name="attr_form_switch_child" value="1"/><span></span> then you can do this on("change:form_switch", function() {         getAttrs(["form_switch"], function(values) {       if (values.form_switch == "0" ) {       setAttrs({form_switch_child: "1"});       }       else if (values.form_switch == "1") {           setAttrs({form_switch_child: "0"});       }     }); }); also I notice in my sheet, the checkboxes return strings 0 or 1, so i compare to that. also just some bugs:   mixed "values" and "value" , and = was used which just sets a value, you want == or ===, i used == to cover both number and string possibilities.  if it's just going to set a field and the css handles everything, then you can set quiet to true this will tell the server not to send an event for the changed checkbox attribute (which should also stop an infinte loop) setAttrs({form_switch_child: "0"},{quiet:true});
I went with your most recent explanation, but changed the code to this: on("change:form_switch", function() {         getAttrs(["form_switch"], function(values) {       if (values.form_switch == "0" ) {       setAttrs({form_switch_child: "0"});       }       else if (values.form_switch == "1") {           setAttrs({form_switch_child: "1"});       }     }); }); ...because i have math on the sheet based on the value of the form-switch, and switching to the opposite was throwing things off.  Hopefully, this will prevent the hanging* that has occurred before. *hit the switch, the switch changes but nothing else.