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 isn't updated from saved attributes

I'm having a lot of trouble with attributes. Some are working - the very simple, text type. But then I have a few that are `type="number"` that aren't working, and this more complicated thing is also not working the way I'd expect:    < h2 > Stress </ h2 >    < p >< fieldset   class = "stress" >      < button   type = "action"   name = "act_dec_stress"   class = "dec" >        < span   class = "peace" > ☮️ </ span >      </ button >      < input   type = "hidden"   class = "toggle"   name = "attr_stress"   />      < span   name = "attr_stressdisplay" ></ span >      < button   type = "action"   name = "act_inc_stress"   class = "inc" >        < span   class = "stress" > ⚡ </ span >      </ button >    </ fieldset ></ p >    < script   type = "text/worker" >     on("clicked:inc_stress", function() {       getAttrs(["stress"], function(values) {         let stress = (parseInt(values.stress)||0) + 1;         setAttrs({           "stress": stress > "5" ? "5" : stress         });       });     });     on("clicked:dec_stress", function() {       getAttrs(["stress"], function(values) {         let stress = (parseInt(values.stress)||0) - 1;         setAttrs({           "stress": stress < "0" ? "0" : stress         });       });     });     on("change:stress", function(){        getAttrs(["stress"], function(values) {         let stress = parseInt(values.stress)||0;         let stress_display = "";         for(i=0; i < stress; i++) {           stress_display = stress_display + "⚡"         }         console.log("stress", stress, "display", stress_display)         setAttrs({           "stressdisplay": stress_display         });       });     });    </ script > The `stress_display` attribute in the attributes tab updates when the buttons are clicked, but the span with the `name` `stress_display` does not get updated. Any ideas why this might be?
Of course I figured it out right after requesting help. For some reason, using a `fieldset` tag interferes with the update. Once I remove the `fieldset` wrapper, the update worked!
1594128045
Andreas J.
Forum Champion
Sheet Author
Translator
Fieldsets are meant for creating repeating sections, and handling stats in them is slightly different from regular stats. The wiki have documentation on this .
1594157456
GiGs
Pro
Sheet Author
API Scripter
As a bit more clarification, a fieldset is actually a set of instructions for building repeating attributes. The attributes you put in there are only partial attributes. When the sheet is opened, the full name for those attributes is generated, and will look something like this: repeating_stress_-rohu1546726_stress repeating_stress_-rohu1546726_stressdisplay This made of three parts: the repeating section name, a row id (that random string of numbers and letters), and the attribute name you defined in the fieldset. In sheet workers, you need to use the full names when working with attributes in a repeating section. There are several ways of getting the name, and Andreas' link describes that.