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

[Custom Sheet] Attributes not showing 'default' value

Hey everyone! I have a problem: when I set the value of certain attributes in the HTML file of my custom sheet, the value doesn’t actually appear on the sheet. It might seem like a minor issue, but it forces me to manually enter 0 for ALL attributes every time I create a new character. Here’s the code for one of the many attributes where the 'default' value I set isn’t being read: <td><input type="text" style="width: 45px;" name="attr_Oratoria_Skill" Value="0" /></td> <td><input type="text" style="width: 45px;" name="attr_Oratoria_mod" Value='0'/></td> Here is the code for a value that, surprisingly, works. What is the difference? What should I change to make all the values display correctly? <input style='display:inline; text-align:center; font-weight:bold;' type="number" name="attr_TFor" class="sheet-carac2" value="10" /> Thank you!
1740683053

Edited 1740684259
GiGs
Pro
Sheet Author
API Scripter
The word value in the second example is in lower case. Try that in the first ones. (HTML tags should be lower case.) This is probably a case of HTMLs fault-tolerance. In Javascript, if you use the wrong syntax for something, the code crashes. In html, the error is simply ignored and discarded, but the rest of the code runs. In your code, that default value is not being set because V alue="0" is ignored and discarded. By the way, I'd avoid starting any attribute names with a number - it complicates the syntax if that attribute is ever used in a sheet worker. (On a second read, that's probably a capital o - if so, ignore this line.)
1740688337

Edited 1740700977
GiGs, you're a lifesaver! Yeah, it was indeed a capital letters problem. Again. Ahaha
1740738944
GiGs
Pro
Sheet Author
API Scripter
:)
1740832892
Mago
Pro
Sheet Author
my OCD self compels me to add that you should be consistent with using the quotes inside code lines like ( " " ) instead of ( ' ' ) either doble quotes for everything or single quotes for everything i just cant... look at it....
1740841032

Edited 1740866809
GiGs
Pro
Sheet Author
API Scripter
I'm guessing they were consistent, but were trying different things to see what was causing the error there, To me the more egregious element was including inline styles instead of classes, but that doesn't cause the code to break.
Thanks for pointing that out! To be honest, I have to admit that I get by with coding without having properly studied it, so I often use the few things I've understood or quickly find on the internet to try to make things work somehow for my personal use. Alas, that's all I can do. For example, I admit that I'm not good at creating classes in CSS files.
1741349754

Edited 1742379748
GiGs
Pro
Sheet Author
API Scripter
Creating classes is easier than you think, though can seem tedious at first. But you soon get over that feeling. At some point, you figured out how to include style commands, as in here <td><input type="text" style="width: 45px;" name="attr_Oratoria_Skill" Value="0" /></td> <td><input type="text" style="width: 45px;" name="attr_Oratoria_mod" Value='0'/></td> Whenever you repeat the same style command, classes are very handy. The first thing you need to do is come up with a name for the class. then you just replace the style with that, for instance: <td><input type="text" class="skill-width" name="attr_Oratoria_Skill" Value="0" /></td> <td><input type="text" class="skill-width" name="attr_Oratoria_mod" Value='0'/></td> Then you need to create a css declaration which contains the name and the style information, like this, in the CSS file. .skill-width { width: 45px; } This is exactly the same as the inline stye, just you normally place each style on a separate line, like .skill-width { width: 45px; color: red; } Now wherever the class is named in the html, that style will be applied. There are other advantages to using a class over an inline style, but that is the main one to think about: if you later decide you want to apply different styles, you just need to change the CSS declaration once, and it is applied everywhere in your HTML instantly. The main downside is you have to sometimes think about specificity - how specific the declaration is. Number inputs are especially fiddle abut this, and you might need to make the class declaration more specific, like this: .ui-dialog .charsheet .skill-width { width: 45px; color: red; } Sometimes changes aren't displayed until you make the code more specific (which means, including more references that actually apply: all character sheets have .ui-dialog .charsheet before their apparent code, so they are always safe to include and you usually don't need anything more).
Thank you so much as always GiGs! I will try it