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

Select is changing but not the value

1594750942
Eli N.
Pro
Compendium Curator
So I have three drop down selections that give bonuses/penalties to fatigue. These three attributes are contained inside a drop down. There is no reference to these selects anywhere else in the character sheet.  Previously I had the issue where if there were two options with the same value it would revert to the value higher on the select, that is why some values have 0+0. However this issue is that if for example if you choose "Small or Medium" under fatigue_shield, then it will add 1 to the fatigue, just like its supposed to. Then if you re-open the sheet, it will revert back to "None", HOWEVER, fatigue hasn't changed its value.                  <div class="sheet-col-3-8">Shield</div>                 <div class="sheet-col-3-8">                     <select name="attr_fatigue_shield">                                                                        <option value="0">None</option> <option value="0+0">Buckler</option>                         <option value="1">Small or Medium </option>                         <option value="2">Large</option>                         <option value="3">Body</option> </select> </div>                 <div class="sheet-col-3-8">Armor</div>                 <div class="sheet-col-3-8">                     <select name="attr_fatigue_armor"> <option value="0">None</option> <option value="0+0">Light</option>                         <option value="1">Medium </option>                         <option value="2">Heavy</option> </select> </div>                 <div class="sheet-col-3-8">Weight</div>                 <div class="sheet-col-3-8">                     <select name="attr_fatigue_weight"> <option value="0">Healthy</option>                         <option value="1">Overweight</option>                         <option value="3">Obese</option>     </select>                 </div>
1594761348

Edited 1594761404
Is this happening with all three select fields? Can you find these fields in the Attributes list in the Attributes & Abilities tab? Is there a sheetworker doing anything with these attributes?
1594852081
vÍnce
Pro
Sheet Author
Are your selects inside a repeating section(fieldset)?  If so, double check that the repeating class name is properly formatted.  Basically, starts with "repeating_", uniquely named, lowercase and no underscores.  Also, shouldn't be an issue here, but I like to choose a default value for selects. ie <option value="0" selected>Healthy</option>
1594853121
Eli N.
Pro
Compendium Curator
They are not in a repeating field, but I will try the default value thing. 
1594853971
GiGs
Pro
Sheet Author
API Scripter
In addition to the previous questions: How is the fatigue value being set? When the dropdown changes, have you tested that the fatigue_shield value matches what is shown in the dropdown?  As an aside, I need to say I'm not a fan of this approach:                     <select name="attr_fatigue_shield">                                                                        <option value="0">None</option> <option value="0+0">Buckler</option>                         <option value="1">Small or Medium </option>                         <option value="2">Large</option>                         <option value="3">Body</option> </select> While it works, if all youre doing is taking that value and adding it as part of a macro or autocalc field, there are serious problems with it if you want to expand your code (like, for instance, get the weight of a shield based on its type, get its armour value, get its fatigue value when armour various from fatigue, and so on). You dont have to use numbers for the value. You can do something like                     <select name="attr_shield_type">                                                                        <option selected>None</option> <option>Buckler</option>                         <option>Small</option>                         <option>Medium </option>                         <option>Large</option>                         <option>Body</option> </select>                     <input name="attr_fatigue_shield" type="hidden" value="0"> When you dont define a value, the option value will equal the text inside the <option></option> section. You can then use a sheet worker to return a value that matches the shield name. on('change:shield_type', function(){     getAttrs(['shield_type'], function(v){         const shield_values = {'None': 0, 'Buckler': 0, 'Small': 1, 'Medium': 1, 'Large': 2, 'Body': 3};         const shield_type = v.shield_type;         const fatigue_shield = shield_values[shield_type];         setAttrs({fatigue_shield});     });  }); If the sheet worker is inside a repeating section this would need a tweak. This would set your fatigue_shield attribute to the appropriate value, and allows you to use shield name for other things if you choose to - like getting the shield weight, or if fatigue and armour values vary, and so on. Ditto for armour.
1595009644
Eli N.
Pro
Compendium Curator
So after fiddling around with the code. The code is contained inside a drop down fieldset, and when I remove the fieldset it works. 
1595062475

Edited 1595062520
GiGs
Pro
Sheet Author
API Scripter
What's the repeating section called? Try changing each instance of repeating_section  in the code below with your actual repeating section name. It's on the 1st, 2nd, 4th, and 7th lines. Be careful to keep any surrounding characters the same (the colons on the first line, and underscores everywhere else). on('change:repeating_section:shield_type', function(){     getAttrs(['repeating_section_shield_type'], function(v){         const shield_values = {'None': 0, 'Buckler': 0, 'Small': 1, 'Medium': 1, 'Large': 2, 'Body': 3};         const shield_type = v.repeating_section_shield_type;         const fatigue_shield = shield_values[shield_type];         setAttrs({             repeating_section_fatigue_shield: fatigue_shield         });     });  });
1595182542

Edited 1595182557
Eli N.
Pro
Compendium Curator
So this is the fieldset it's in, its not a repeating field.  <fieldset class="sheet-col-1-2">                 <input type="checkbox" class="wombat-show arrow" name="attr_fatigue_wombat_show" title="Show/Hide" value="1">                 <span>Base Fatigue Details</span>                 <div class="wombat">                 <div class="sheet-col-3-4">These automatically apply to base fatigue</div>                 <div class="sheet-col-3-8">Shield</div>                 <div class="sheet-col-3-8">                     <select name="attr_fatigue_shield">     <option value="0">None</option>     <option value="0+0">Buckler</option>                         <option value="1">Small or Medium </option>                         <option value="2">Large</option>                         <option value="3">Body</option>     </select> </div>                 <div class="sheet-col-3-8">Armor</div>                 <div class="sheet-col-3-8">                     <select name="attr_fatigue_armor">     <option value="0">None</option>     <option value="0+0">Light</option>                         <option value="1">Medium </option>                         <option value="2">Heavy</option>     </select> </div>                 <div class="sheet-col-3-8">Weight</div>                 <div class="sheet-col-3-8">                     <select name="attr_fatigue_weight">     <option value="0">Healthy</option>                         <option value="1">Overweight</option>                         <option value="3">Obese</option>     </select>                 </div>                 <div class="sheet-col-3-8">Misc</div>                 <div class="sheet-col-3-8"><input type="number" name="attr_fatigue_misc" value="0"/></div>    </div>    </fieldset>
1595199456

Edited 1595199515
vÍnce
Pro
Sheet Author
Fieldsets are treated as repeating sections by roll20 and require special handling.&nbsp; <a href="https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections</a> That might be the source of your problems.&nbsp; If you do not need a repeating section, why not replace it with a div?&nbsp; Otherwise you'll need to make allowances for roll20'sw handling of fieldsets.
1595210092
GiGs
Pro
Sheet Author
API Scripter
As Vince says, anything you put in a fieldset in roll20 is a repeating section. If you put attributes inside a fieldset, they'll be treated as a repeating section, and you won't be able to access them unless you use repeating section syntax. The only reason the fieldset tag exists on roll20 is for repeating sections, and if you try to use it for anything else, it wont work as you expect.
1595248523
Eli N.
Pro
Compendium Curator
I had no idea about that. Yeah, I'll have to go and change that. Thanks guys.&nbsp;