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 .
×

Limiting Fieldset Size (Number of Elements or Rows)

I am trying to limit the number of times the add button can be used within a given field set. My current html looks something like this; &lt;div class="row"&gt; &nbsp; &lt;h2&gt;CustomTemplate&lt;/h2&gt; &nbsp;&nbsp;&nbsp; &lt;input type="text" name="attr_templatename" /&gt; &nbsp;&nbsp;&nbsp; &lt;fieldset class="repeating_templaterow"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;Left:&lt;/span&gt;&lt;input type="text" name="attr_rowlefttext" /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt;Right:&lt;/span&gt;&lt;input type="text" name="attr_rowrighttext" /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt; Dice:&lt;/span&gt;&lt;input type="number" name="attr_rowdice" value="0" /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt; TN&lt;/span&gt;&lt;input type="number" name="attr_rowbasetn" value="0" /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;span&gt; with &lt;/span&gt;&lt;input type="number" name="attr_rowas" value="0" /&gt;&lt;span&gt;AS.&lt;/span&gt; &nbsp;&nbsp;&nbsp; &lt;/fieldset&gt; &nbsp;&nbsp;&nbsp; &lt;button type='roll' name='roll_mytemplate' title='%{selected|mytemplate}' value='&amp;{template:default} {{name=@{character_name} : &amp;#x00A;@{templatename}}} {{@{repeating_templaterow_$0_rowlefttext}=[[2D10]]}} {{@{repeating_templaterow_$1_rowlefttext}=[[2D10]]}} {{@{repeating_templaterow_$2_rowlefttext}=[[2D10]]}} {{@{repeating_templaterow_$3_rowlefttext}=[[2D10]]}}'&gt;&lt;span&gt;Roll &lt;/span&gt;&lt;span name="attr_templatename"&gt;&lt;/span&gt; &lt;/div&gt; It works, but As there are only 0-3 in the template, I was looking for a (preferably easy) way to limit the number of rows that could be added... (I was originaly trying to do them as nested fieldsets so that the character could have N of these custom templates but given this post <a href="https://app.roll20.net/forum/post/2942465/nested-repeating-sections" rel="nofollow">https://app.roll20.net/forum/post/2942465/nested-repeating-sections</a> I gave up on that idea and am just going to add a few to the bottom of the sheet.
Do you have a hard upper limit maximum for how many of these a character could need? If it's not too many, you could hard code them all as regular HTML elements and attributes, and not use repeating sections.
I was trying to avoid that as there is a lot more to go in the row (and fieldset) to pull in things like wound modifiers and I just KNOW I will make a copy paste error that is impossible to find.
1593274598

Edited 1593274921
Finderski
Pro
Sheet Author
Compendium Curator
You could probably use CSS to hide the button. This would require a hidden input that updated with the total number of rows in the fieldset via a sheet worker. Edit... To clarify, you'd want something like this in your CSS: .sheet-hiderepeating[value=4] ~ [data-groupname=repeating_sectionname] &gt; .repcontrol_add { display: none; } Then, once your repeating number hit 4, the Add button will disappear, but the Modify button remain. &nbsp;The above is untested so may require some fiddling around...
1593274905
GiGs
Pro
Sheet Author
API Scripter
generally speakijng, if you have a fixed maximum size of a repeating section, its better top do it as a non-repeating section, as Rabulias says. Because repeating sections are a bit of a pain for users when they want to create macros. We only use repeating sections because its the only way to achieve dynamic, variable sized groups, but non-repeating sections have much better syntax. However if you do want to keep using repeating sections, one way to do it is with a sheet worker: run whenever the section changes, count the number of rows, and if its above the maximum, delete the last row (which will always be the one just added). Finderski's method of hiding the add button is smoother though. You might not need to use a sheet worker to count the rows, css has a counter property that might work.&nbsp;
1593274993
Finderski
Pro
Sheet Author
Compendium Curator
GiGs said: You might not need to use a sheet worker to count the rows, css has a counter property that might work.&nbsp; I will have to look into this...never knew that. :)