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

Controls to add or subtract from a field value

1411665945
chatty
KS Backer
Sheet Author
I'm sorry for asking this, but I've got really limited time to work on sheets, and I am trying to build a Gumshoe (Night's Black Agents in particular) sheet. Do any of the currently-extant sheets have controls that let you press a button to increment or decrement a score? I'm pondering something that keeps track of pool point spends in Gumshoe. You click "Spend" and it adds to a "spent" field and subtracts from a "remaining" field. I have no idea how to build that, but if something similar already exists, I could probably hack at the HTML til it did what I want. Thanks! C
1411674901

Edited 1411675844
Lithl
Pro
Sheet Author
API Scripter
<input type="number">, in most browsers, will include up/down arrows on the right side of the input to increment/decrement the value. You can also include a step amount to set how much the arrows increment/decrement by: <input type="text" step="3"> would increase the value by 3 when you click the up arrow. The max and min attributes can put bounds on the input value in each direction (and omitting either or both of them leaves no bound in that direction). There is no direct means of creating an arbitrary button to increment/decrement a value. There is some capability to change the style of the up/down arrows in a number input using CSS ( example fiddle ): input[type=number].sheet-my-modified-number-input::-webkit-outer-spin-button, input[type=number].sheet-my-modified-number-input::-webkit-inner-spin-button { /* styles for both outer and inner */ } This trick should only work for WebKit browsers (Safari and Chrome). Firefox can hide the spinners entirely with something like input[type=number].sheet-my-modified-number-input { -moz-appearance: textfield; } , but can't do much other styling (there are other values for -moz-appearance , of course). Opera does not currently support the Shadow DOM, I believe, so you can't do any styling there. I don't believe there's any spin button styling for Internet Explorer, although a cursory internet search implies that IE might respect the WebKit selectors. If the value you wish to change has a finite range, you could implement a cycling button ; the value would only go one direction, but it would reset to the initial value after you reach the last value and try to advance again. This would let you give an arbitrary appearance to your button, if you so chose.
1411693066
chatty
KS Backer
Sheet Author
At first I didn't like them, but once I learned to play with the CSS to adjust the field size, I think the increment/decrement arrows are fine. Thanks! I think I should probably work with the cycling button and the arrow style just for the practice, but for now, a sheet that more or less does what I want is fine.