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

Limit maximum by other value

1590041288
Chomik
Pro
Sheet Author
I like to limit Stamina Points ( HP ) to be able only to choose up to SP Max value, nothing more. Here is example I use:   <div class="sheet__stamina-points">    <h2>Stamina Points</h2><br />    <table>    <tr>    <td>   <label>Current</label></td>   <td><label>Max</label></td>   </tr> <tr>     <td>   <input class="input" type="number" name='attr_sp'></td>   <td><input class="input" type="number" name='attr_sp_max' ></td></tr>   </table><br/>    </div> Using line  <input class="input" type="number" name='attr_sp' max='attr_sp_max'> does not seems to limit values. :/
1590046808
GiGs
Pro
Sheet Author
API Scripter
The only way to limit stats is by using a sheet worker. You can check if the value exceeds the max and reset it to max. on('change:sp', () => {     getAttrs(['sp','sp_max'], values => (         let current = parseInt(values.sp) || 0;         let max = parseInt(values.sp_max) || 0;         if(current > max) {                 setAttrs({                     sp: max                 });         }     }); });
1590049930
Chomik
Pro
Sheet Author
It's weird, as I did limit max values simply by declarations on my other sheet, Werewolf the Forsaken one - in this direct section. <div class="sheet-col"> <h3>Health</h3> <div class="sheet-healthboxcontainer"> Max: <input type="number" name="attr_monhealthmax" min="1" max="30"> Now: <input type="number" name="attr_monhealth" min="0" max="attr_monhealthmax"> <br> <div class="sheet-hbspace"> <input type="radio" class="sheet-healthbox sheet-empty" name="attr_monhealth1" value="0"> <span></span> <input type="radio" class="sheet-healthbox sheet-bash" name="attr_monhealth1" value="1"> <span></span> <input type="radio" class="sheet-healthbox sheet-leth" name="attr_monhealth1" value="2"> <span></span> <input type="radio" class="sheet-healthbox sheet-agg" name="attr_monhealth1" value="3"> <span></span> <input type="radio" class="sheet-healthbox sheet-blank" name="attr_monhealth1" value="4" checked="checked"> <span></span> </div>
1590051775
GiGs
Pro
Sheet Author
API Scripter
You should test that again. the max property wont work in roll20. It might work if you are incrementing values using a spinner, but the player can just enter any value they want in the input box.