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

Autocalc from checkboxes

1589842077

Edited 1589871556
Chomik
Pro
Sheet Author
I have char sheet based loosely on D&D 5E OGL. I made nicely sheet to calculate Ability Modifiers with those elements:  <input class="input" type="number" name="attr_str" value="10"/>  <input class="input" type="number" disabled="true" name="attr_str_mod" value="floor((@{str}-10)/2)" /> So it's clear that str_mod is calcuated from str attribute. However, when I want to use the same method to check what is taken in prof attribute - I get blank, empty cell. :/  <div class="sheet_proficiency">       <label>Proficiency Bonus </label><input type="number" name='attr_prof' /><br/>    </div>    <br/>    <input class="input" type="number" name='txt_prof' value="@{prof}" /> I do not understand what's going further with it - adding prof value to the sav_thr_str when checkbox marked is much further away then? Cause even without checboxes marked, sheet should simply take str_mod and put in sav_thr_str_val , don't it? <td><input type='checkbox' name='sav_thr_str' value="@{prof}" /></td>    <td><label>Strength </label> </td>   <td><input class="input" type="number" name='sav_thr_str_val' value="@{str_mod}" /></td>
1589859806
GiGs
Pro
Sheet Author
API Scripter
Try setting a value in the prof input: <input type="number" name='attr_prof' value="0"/>
1589868239

Edited 1589868327
Chomik
Pro
Sheet Author
GiGs said: Try setting a value in the prof input: <input type="number" name='attr_prof' value="0"/> Used above line - nothing changed... Too show that autocalc on my str_mod works - here is Abilities table...
1589874774
GiGs
Pro
Sheet Author
API Scripter
OH! youre' missing the disabled="true" in the second input <input class="input" type="number" name='txt_prof' value="@{prof}" disabled="true" /> This is what makes it act as an autocalc field.
1589879814
Chomik
Pro
Sheet Author
GiGs said: OH! youre' missing the disabled="true" in the second input <input class="input" type="number" name='txt_prof' value="@{prof}" disabled="true" /> This is what makes it act as an autocalc field. Copied your line. Still get's this, even if filling prof with number 2...
1589879951
GiGs
Pro
Sheet Author
API Scripter
I just spotted another error: hopefully this is the last! <input class="input" type="number" name=' attr_ txt_prof' value="@{prof}" disabled="true" /> names always need attr_ at the start. It's not actually part of the name, its a flag to tell roll20 that what follows is an attribute name.
1589888555

Edited 1589888991
Chomik
Pro
Sheet Author
iGs ,thank you a lot! So adding attr_ prefix and making cells disabled start to work autocalc - so tahnks for this! It works (!) that marking chekbox add str_mod to prof numbers, yes!  ( str_mod = 3 in example ) And when I mark the checkbox - got correct numbers! Here is working (!) code: <div class="sheet_proficiency"> <label>Proficiency Bonus </label><input type="number" name='attr_prof' value="0"/><br/> </div> <br/> <input class="input" type="number" disabled="true" name='attr_txt_prof' value="@{prof}" disabled="true" /> <div class="sheet__saving_throws" > <form> <h2>Saving Throws</h2> <table> <tr> <td> <input type='checkbox' name='attr_sav_thr_str' value="@{prof}" /></td> <td><label>Strength </label> </td> <td><input class="input" type="number" disabled="true" name='attr_sav_thr_str_val' value="@{str_mod}+@{sav_thr_str}" /></td> </tr> I will just clear it to make attr_sav_thr_str main atrribute at result of calculation, as I may need to use it in macros later on. ;)  NEXT ASSIGNMENT - Using this knowledge to make Skills autocalculation... ;)
1589889257
GiGs
Pro
Sheet Author
API Scripter
Yay! One thing I'd suggest is using readable attribute names. This  sav_thr_str_val is abbreviated a bit more than needed. You could call it, say, strength_save, or save_strength, to make it more understandable.  
1589889531
Chomik
Pro
Sheet Author
GiGs said: Yay! One thing I'd suggest is using readable attribute names. This  sav_thr_str_val is abbreviated a bit more than needed. You could call it, say, strength_save, or save_strength, to make it more understandable.   I use abbreviated to use them on macros later on - experience I came from playing on D&D 5E sheets by two months now. But maybe save_str will be much better in general use, yes.
1589896348

Edited 1589899278
Chomik
Pro
Sheet Author
Made the same calculations with Skills list for Realms of Pugmire . I only have some enigmatic extra sign '<' I cannot find in the code. :( / ALMOST perfect... / <div class="sheet__skills"> <h2>Skills</h2> <table> <tr> <td></td> <td><label><b>Strength</b></label></td> <td></td> <td></td> <td><label><b>Constituion</b></label></td> <td></td> <td></td> <td><label><b>Intelligence</b></label></td> <td></td> <td></td> <td><label><b>Wisdom</b></label></td> <td></td> </tr> <tr> <td><input type='checkbox' name='attr_intimidate_chk' value="@{prof}" /></td> <td><label>Intimidate</label></td> <td><input class="input" type="number" disabled="true" name="attr_intimidate" value="@{str_mod}+@{intimidate_chk}" /></td> <td><input type='checkbox' name='attr_traverse_chk' value="@{prof}" /></td> <td><label>Traverse</label></td> <td><input class="input" type="number" disabled="true" name="attr_traverse" value="@{con_mod}+@{traverse_chk}" /></td> <td><input type='checkbox' name='attr_karcana_chk' value="@{prof}" /></td> <td><label>Know Arcana</label></td> <td><input class="input" type="number" disabled="true" name="attr_karcana" value="@{int_mod}+@{karcana_chk}" /></td> <td><input type='checkbox' name='attr_handle_animal_chk' value="@{prof}" /></td> <td><label>Handle Animal</label></td> <td><input class="input" type="number" disabled="true" name="attr_handle_animal" value="@{wis_mod}+@{handle_animal_chk}" /></td> </tr> <tr> <td></td> <td><label><b>Dexterity</b></label></td> <td></td> <td></td> <td><label><b>Charisma</b></label></td> <td></td> <td><input type='checkbox' name='attr_kculture_chk' value="@{prof}" /></td> <td><label>Know Culture</label></td> <td><input class="input" type="number" disabled="true" name="attr_kculture" value="@{int_mod}+@{kculture_chk}" /></td> <td><input type='checkbox' name='attr_heal_chk' value="@{prof}" /></td> <<td><label>Heal</label></td> <td><input class="input" type="number" disabled="true" name="attr_heal" value="@{wis_mod}+@{heal_chk}" /></td> </tr> <tr> <td><input type='checkbox' name='attr_balance_chk' value="@{prof}" /></td> <td><label>Balance</label></td> <td><input class="input" type="number" disabled="true" name="attr_balance" value="@{dex_mod}+@{balance_chk}" /></td> <td><input type='checkbox' name='attr_bluff_chk' value="@{prof}" /></td> <td><label>Bluff</label></td> <td><input class="input" type="number" disabled="true" name="attr_bluff" value="@{cha_mod}+@{bluff_chk}" /></td> <td><input type='checkbox' name='attr_khistory_chk' value="@{prof}" /></td> <td><label>Know History</label></td> <td><input class="input" type="number" disabled="true" name="attr_khistory" value="@{int_mod}+@{khistory_chk}" /></td> <td><input type='checkbox' name='attr_notice_chk' value="@{prof}" /></td> <td><label>Notice</label></td> <td><input class="input" type="number" disabled="true" name="attr_notice" value="@{wis_mod}+@{notice_chk}" /></td> </tr> <tr> <td><input type='checkbox' name='attr_sneak_chk' value="@{prof}" /></td> <td><label>Sneak</label></td> <td><input class="input" type="number" disabled="true" name="attr_sneak" value="@{dex_mod}+@{sneak_chk}" /></td> <td><input type='checkbox' name='attr_perform_chk' value="@{prof}" /></td> <td><label>Perform</label></td> <td><input class="input" type="number" disabled="true" name="attr_perform" value="@{cha_mod}+@{perform_chk}" /></td> <td><input type='checkbox' name='attr_knature_chk' value="@{prof}" /></td> <td><label>Know Nature</label></td> <td><input class="input" type="number" disabled="true" name="attr_knature" value="@{int_mod}+@{knature_chk}" /></td> <td><input type='checkbox' name='attr_search_chk' value="@{prof}" /></td> <td><label>Search</label></td> <td><input class="input" type="number" disabled="true" name="attr_search" value="@{wis_mod}+@{search_chk}" /></td> </tr> <tr> <td><input type='checkbox' name='attr_steal_chk' value="@{prof}" /></td> <td><label>Steal</label></td> <td><input class="input" type="number" disabled="true" name="attr_steal" value="@{dex_mod}+@{steal_chk}" /></td> <td><input type='checkbox' name='attr_persuade_chk' value="@{prof}" /></td> <td><label>Persuade</label></td> <td><input class="input" type="number" disabled="true" name="attr_persuade" value="@{cha_mod}+@{persuade_chk}" /></td> <td><input type='checkbox' name='attr_kreligion_chk' value="@{prof}" /></td> <td><label>Know Religion</label></td> <td><input class="input" type="number" disabled="true" name="attr_kreligion" value="@{int_mod}+@{kreligion_chk}" /></td> <td><input type='checkbox' name='attr_sense_motive_chk' value="@{prof}" /></td> <td><label>Sense Motive</label></td> <td><input class="input" type="number" disabled="true" name="attr_sense_motive" value="@{wis_mod}+@{sense_motive_chk}" /></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td><input type='checkbox' name='attr_survive_chk' value="@{prof}" /></td> <td><label>Survive</label></td> <td><input class="input" type="number" disabled="true" name="attr_survive" value="@{wis_mod}+@{survive_chk}" /></td> </tr> </table>
1589898567
GiGs
Pro
Sheet Author
API Scripter
This is your problem <<td><label>Heal</label></td> Heal has two << where there should only be one. By the way, if you are planning to submit this sheet to roll20 for community use, you should know that they wont accept sheets that use tables for layout. You'd need to rework the sheet to lay things out using css instead of tables.