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
This post has been closed. You can still view previous posts, but you can't post any new replies.

Default value for select when selecting an empty value option

July 03 (8 years ago)
Kryx
Pro
Sheet Author
API Scripter
I have the following html:
<select name="attr_initiative_ability">
  <option value="">—</option>
  <option value="strength" data-i18n="STR">Str</option>
  <option value="dexterity" data-i18n="DEX" selected>Dex</option>
  <option value="constitution" data-i18n="CON">Con</option>
  <option value="intelligence" data-i18n="INT">Int</option>
  <option value="wisdom" data-i18n="WIS">Wis</option>
  <option value="charisma" data-i18n="CHA">Cha</option>
</select>

If I select the first item I get the following in the console:
FILLED IN A DEFAULT VALUE FOR initiative_ability
And then dexterity is re-selected. Though this only happens once.

I assume there is a check for a value and if no value is found then it sets it to the selected value. However it should be checking for undefined instead.

Thanks!
July 03 (8 years ago)
Coal Powered Puppet
Pro
Sheet Author
When I make sheets, for select boxes, I usually make the first section have a value equal to zero, so any associated button works but doesn't add anything. 
<select name="attr_initiative_ability">
  <option value="0">—</option>
  ...
  ...

</select>
July 03 (8 years ago)
Kryx
Pro
Sheet Author
API Scripter
I understand that I can make it 0, but I don't want the value to be 0. I want it to be empty.
July 05 (8 years ago)

Edited July 05 (8 years ago)
Phil B.
Forum Champion
Sheet Author
This is something we have looked at and discussed many times amongst the dev team. The problem is that the way FireBase works is that a blank value is turned into "no value", to save space, and we assume that "no value" means "use the default value". This is why, also, when a sheetworker sets a value to "" the sheet doesn't actually show the change because the value is deleted rather than "changed" and the sheet can't track changes on a value that doesn't exist any more.

If we changed this behavior it would be difficult for us to be able to tell if "no value" is because it's a new character and we need the use the default value, or if it's "no value" because the value has been set to "" so we show "blank".
July 05 (8 years ago)

Edited July 05 (8 years ago)
Kryx
Pro
Sheet Author
API Scripter
Ah, Understandable Phil. Sorry If I worded the above a bit aggressively.
That's rather unfortunate. I'll have to think of a different way to set a default then - likely via sheetworkers on page creation. This can be closed then - I'll find a different solution.

When you get a chance can you take a peak at An Attribute set to 0 no longer shows on the sheet. A player recently had this come up for them and I don't think I can do any kind of work around to make it work.
July 05 (8 years ago)
Phil B.
Forum Champion
Sheet Author
Yeah, sorry it's an inconvenience and sorry I don't have a better answer than "we tried". It's something we've approached several times and have not found a alternative that isn't worse than the current situation.

P.S. I responded to the other thread.