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

[Bug?] - Checkbox with "checked" is not Initializing

1436042267
Finderski
Pro
Sheet Author
Compendium Curator
I worked out a way to allow players to choose whether to use a roll template with the roll buttons on the character sheet or go without a roll template. This code: &lt;div class="sheet-row"&gt; &lt;div class="sheet-col" style="width: 20%"&gt;Trait Roll Template:&lt;/div&gt; &lt;div class="sheet-col"&gt; &lt;input type="checkbox" class="sheet-rt sheet-rt0" name="attr_skillrt" value="0" title="No Roll Template" /&gt; &lt;span class="sheet-rt sheet-rt0"&gt; &lt;span class="sheet-rtinner"&gt;No Roll Template&lt;/span&gt; &lt;/span&gt; &lt;input type="checkbox" class="sheet-rt sheet-rt1" name="attr_skillrt" value="&{template:solidtrait}" title="Solid Trait Layout" checked /&gt; &lt;span class="sheet-rt sheet-rt1"&gt; &lt;span class="sheet-rtinner"&gt;&lt;img src="<a href="http://www.geeksville.us/roll20/SolidTrait.png" rel="nofollow">http://www.geeksville.us/roll20/SolidTrait.png</a>" value="Ace of Spades Card Template" /&gt;&lt;/span&gt; &lt;/span&gt; &lt;input type="checkbox" class="sheet-rt sheet-rt2" name="attr_skillrt" value="&{template:spadestrait2}" title="Ace of Spades Trait Layout" /&gt; &lt;span class="sheet-rt sheet-rt2"&gt; &lt;span class="sheet-rtinner"&gt;&lt;img src="<a href="http://www.geeksville.us/roll20/SpadesTrait.png" rel="nofollow">http://www.geeksville.us/roll20/SpadesTrait.png</a>" value="Ace of Spades Card Template" /&gt;&lt;/span&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; The line that is bolded is the one that should initialize, but it fails to do so. When you create a new Character, character sheet shows it as checked: But, attr_skillrt has a default value of 0: NOTE: The 0 in front of {{name=Prem Plaev}} is the call for @{skillrt} in the button code. At first I thought it was because it was the first checkbox, so I moved to the last position (as the picture shows), but that didn't solve the problem either (so I moved it back, which is what the code shows above shows). Any thoughts on how to solve this problem?
1436042848
Lithl
Pro
Sheet Author
API Scripter
Is this in a repeating section? Not sure if it makes a difference in this case, but repeating sections are notorious for not behaving identically to the rest of the sheet. Another suggestion would be to try checked="true" or checked="checked". Simply having the attribute present is supposed to be correct HTML, but it can't hurt to be extra specific.
1436045824
Finderski
Pro
Sheet Author
Compendium Curator
Not part of a repeating section. On your suggestion I did try checked="true" and checked="checked" and even checked=true. None of those worked. :-/ Any other thoughts? (And thanks for the taking the time to look at this, I do appreciate it.)
1436070118

Edited 1436070790
vÍnce
Pro
Sheet Author
G V. said: Not part of a repeating section. On your suggestion I did try checked="true" and checked="checked" and even checked=true. None of those worked. :-/ Any other thoughts? (And thanks for the taking the time to look at this, I do appreciate it.) How about just plain checked/&gt; ? Nevermind. :-) I see you started out with that. Duh. lol UPDATE: Actually... try checked/&gt; no spaces.
1436087774
Finderski
Pro
Sheet Author
Compendium Curator
Nice idea, Vince, but didn't work. :(
1436183799
Kryx
Pro
Sheet Author
API Scripter
Hmmm, strange that it doesn't work for you. I recently implemented this on my crit in 5e and it works. You need to include the whole block - the button that prints out @{skillrt} seems quite important. Here is my code example that works: &lt;input type="hidden" name="attr_repeating_weapons_melee_0_var_crit" value="{{can_crit=1}}"&gt; &lt;input type="checkbox" name="attr_repeating_weapons_melee_0_toggle_crit" value="@{repeating_weapons_melee_0_var_crit}" checked&gt; &lt;button type="roll" name="roll_repeating_weapons_melee_0_weapon" value="@{repeating_weapons_melee_0_toggle_crit}"&gt;&lt;/button&gt; I'd have to verify that it works in this format but that should work. And that's not really any different from what you have...
1436187594
Finderski
Pro
Sheet Author
Compendium Curator
Mark, you raise a good point and I realize neglected to include the code for the buttons and the CSS related to that. Here's my code for that: HTML: &lt;input class="sheet-buttonbox" type="checkbox" name="attr_skillrt" value="0" style="display:none;" /&gt; &lt;button class="sheet-templatebutton" type='roll' name='roll_tAgilityRoll' title="@{tAgilityRoll}" value='@{skillrt} @{rolltAgility}' &gt;&lt;/button&gt;&lt;button class="sheet-templatebutton sheet-GM-button" type='roll' name='roll_tgmAgilityRoll' title="@{tgmAgilityRoll}" value='/w gm @{skillrt} @{rolltAgility}'&gt;&lt;/button&gt; &lt;button class="sheet-normalbutton" type='roll' name='roll_AgilityRoll' title="@{AgilityRoll}" value='/em @{character_name} attempts to be agile and rolls @{rollAgility}'&gt;&lt;/button&gt;&lt;button type='roll' class="sheet-normalbutton sheet-GM-button" name='roll_gmAgilityRoll' title="@{gmAgilityRoll}" value='/w gm @{character_name} attempts to be agile and rolls @{rollAgility}'&gt;&lt;/button&gt; &lt;input type='hidden' name='attr_rollAgility' value='[[{1d@{agility}![Agility],1d@{wilddie}![Wild Die]}kh1 +@{agMod}[Agility Rank Modifier] + @{agrollMod}[Agility Roll Modifier] + @{ttmod}[Trait Test Modifier] + @{encumbrance}[Encumbrance Penalty] - @{woundsMod}[Wounds] - @{fatigue}[Fatigue]]]' /&gt; &lt;input type='hidden' name='attr_rolltAgility' value='{{name=@{character_name}}} {{skill_name=Agility}} {{skill_rank=@{Agility}}} {{skill_rank_mod=@{agMod}}} {{att_mod=@{agrollMod}}} {{ttmod=@{ttmod}}} {{enc=[[@{encumbrance}]]}} {{wounds= -[[@{woundsMod}]]}} {{fatigue= -@{fatigue}}} {{skill_roll=[[1d@{agility}! + @{agMod} + @{agrollMod}[Skill Modifier] + @{ModSumEnc}[Other Modifiers]]]}} {{wild_die_rank=@{wilddie}}} {{wild_die=[[1d@{wilddie}! + @{agMod} + @{agrollMod}[Skill Modifier] + @{ModSumEnc}[Other Modifiers]]]}}' /&gt; CSS: .sheet-normalbutton, .sheet-templatebutton { display: none; } .sheet-buttonbox[value="0"]:checked ~ .sheet-normalbutton { display: inline-block; } .sheet-buttonbox[value="0"]:not(:checked) ~ .sheet-templatebutton { display: inline-block; } I've added an extra line break for ease of readability in this post. I've also bolded the classes that I have in the CSS code to hopefully make it easier to follow. In the output, the weirdness is that the Roll Template button is visible, but the value of @{skillrt} is being listed as 0 (as seen in the screenshot of the chat output). When I go and actively click on one of the options, everything functions correctly, so the only weird part is if I'm not making a selection when a new character sheet is created. I hope this helps.
1436196692
vÍnce
Pro
Sheet Author
I think it may have something to with the 2 attributes having a roll template as their value. As a test, if you change their value to something else, (maybe a number or text that doesn't begin with &{...}), does it work properly?
1436199772
Kryx
Pro
Sheet Author
API Scripter
Vince said: I think it may have something to with the 2 attributes having a roll template as their value. As a test, if you change their value to something else, (maybe a number or text that doesn't begin with &{...}), does it work properly? My thoughts as well. Some things do not like to be passed in and must be done directly on the button. I've found this to be the case with "\n" characters to allow for line breaking out of a roll template.
1436236660
Finderski
Pro
Sheet Author
Compendium Curator
Vince and Mark - again, great suggestions, but still didn't work. I tried just using "template:solidtrait" and when that didn't work I tried "4". In both cases, the value still presented itself as 0.