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 .
×
Our team is currently investigating rolling service outages. For more information, visit our most recent Forum Announcements post.
Create a free account

[Help Needed] Value in Input Box not being added to Die Roll

1458885731
MrBS
Pro
Sheet Author
API Scripter
 I am running into an issue where the value from an input field is not being added to a die roll when the sheet is first opened, the user changes the value in the input field, and immediately clicks on the die rolling button. sample code for the input field: <tr> <td><h6>Skill Modifier:</h6></td> <td><input type="number" name="attr_skill_mod" value="0" style="align:left;"/></td> </tr> And sample button: <tr> <td><button type='roll' title='Skill Roll' value='&{template:skill_roll} {{name=@{character_name} - skill roll}} {{skill=Poor}} {{level=Poor -1}} {{roll=[[4df-1+@{skill_mod}]]}}'></button><span style="margin-left:0px;">Poor Skill (-1)</span></td> </tr> I have been able to duplicate this using the following steps: 1) Upon opening the sheet, click on the input field and change the number. 2) Immediately click on the roll button. 3) The result shows the value prior to the update in #1 4) close the form and reopen, rinse and repeat. If after #1 I click on a different input field the roll shows the updated number.  Also, this only occurs the very first time; if I repeate steps 1 through 3 without closing the form, it will always pull in the updated value. It appears the on-change event is not being triggered to update the underlying field after the sheet is opened when the roll button is clicked immediately after a change to an input field. Is this a known issue? Working as expected? If working as expected, is there a work-around or programatic solution? yada, yada, yada.  Any guidance and help is greatly appreciated!
1458892317

Edited 1458892332
If you don't click or tab out of the input box, there's nothing triggering the scripts to tell Roll20 that something changed. It's like filling out a reply here on the forums and not clicking submit post, but expecting it to show up in the thread anyway.
1458955635

Edited 1458956317
MrBS
Pro
Sheet Author
API Scripter
Thanks HoneyBadger you got me to thinking about the exact sequence of programmatic even triggers and figured out what was going on.  When I keep the mouse cursor hovering over the roll button it shifts focus to the roll button which triggers the update.  If I click the roll button and move the mouse cursor away quickly it would not trigger the change in focus and thus the exit event is not being triggered on the input (which I suspect is the timing of when the update occurs). When I first saw this I would open the character sheet, change the input, click the roll button and quickly go to chat to check the value.  After seeing the value I would go back to the input but found myself lingering longer on the roll button afterward.  When I linger it changes the focus and thus triggers the exit event (and I assume initiates the update) but when I dont linger the exit event is not being triggered; I am presuming its the exit event or equivalent.