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

Datalist option auto-calc

1735598995
Aurelien C.
Pro
Sheet Author
Hey team ! I’m trying to work on a dynamic select. As of right now I’m able to update options of a datalist through the use of a fieldset : < input type = "text" list = "options" name = "attr_option" value = "1" > < datalist id = "options" >     < fieldset class = "repeating_options" >         < input type = "hidden" name = "attr_option_name" value = "Option 1" >         < option value = "@{option_name}" ></ option >     </ fieldset > </ datalist > < fieldset class = "repeating_options" >     < input type = "text" name = "attr_option_name" value = "Option 1" > </ fieldset > Thing is, I want the value of the <option> to reflect the content of the input, be it from sheetworker or auto-calc. Is that possible?
1735602448

Edited 1735602514
vÍnce
Pro
Sheet Author
I was surprised that you could embed a fieldset inside a datalist.  That's cool.  I don't believe it's possible to create a dynamic select though. Maybe if building a Beacon-based sheet.  Perhaps Scott C. or GiGs would know of a method.  Not sure if it works in your use case, but I've created multiple versions of the same <select> and only revealed one(using css to hide/show) based on criteria.
1735602494

Edited 1735602600
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I had never thought of putting a fieldset in a datalist like that. Unfortunately, datalists don't really work well. This isn't a thing about Roll20 but about how browsers handle them. Firefox and Chrome handle them dramatically differently and that goes so far as to change what information is presented to the user vs. what is stored depending on if you use chrome or firefox. In order to get a dynamic list, you can use the populateListOptions sheetworker to dynamically update the options of a select. Note that you need to run the populate on sheet opened as well because the changes are not persistent across openings of the sheet.
1735602686

Edited 1735604505
vÍnce
Pro
Sheet Author
I forgot about that. 8) populateListOptions() Is not in the wiki: sheet worker scripts wth? Added: <a href="https://wiki.roll20.net/Sheet_Worker_Scripts#populateListOptions.28object.29" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts#populateListOptions.28object.29</a> Did it get any further "tuning" by the Devs Scott?
1735602928
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No, but it works very well. I've used it in a couple sheets. There's a few finicky things mostly to do with translations, but those are easily handled.
1735608567
Aurelien C.
Pro
Sheet Author
This looks promising, I’ll tinker with it a bit more but I think this is it ! Thank you for the quick answer !