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

[Request] Access to text of selected

1447677821

Edited 1447677838
I would require a script which gives me the text of the selected option of a <select> element inside of repeating elements. I am able to access the value as @{trigger_entzug{ but I would also require the selected text. <select name="attr_trigger_entzug"> <option value="2">Befehl</option> <option value="1">Kontakt</option> <option value="2">Zeitzünder</option> <option value="2">Ver. Befehl</option> <option value="1">Ver. Kontakt</option> <option value="3">Ver. Kontakt Geschlecht/Metatyp</option> </select> Thanks to anyone who comes up with a solution.
1447682461
Lithl
Pro
Sheet Author
API Scripter
Having multiple options within a select with the same value will make the select function improperly. Also, there is no means to do what you ask without changing the values of the options. I recommend setting the option values to their label text (<option value="foo">foo</option>) and then use sheet workers to accomplish what you're trying to do with the numbers.
Why would that make the select function improperly? I do expect the value to be the same on both options. All options with the same value are expected to be treated as one option, it is nothing more than an interface for the player.
1447702047
Alicia
Sheet Author
Do you need the text to appear in the roll? You could use the inline notes text options for the option if that's the case. <option value="2[Befehl]">Befehl</option> It would then show in the roll as 2[Befehl] when you hover over with the tooltip.
1447744770

Edited 1447744898
Lithl
Pro
Sheet Author
API Scripter
Wandler said: Why would that make the select function improperly? I do expect the value to be the same on both options. All options with the same value are expected to be treated as one option, it is nothing more than an interface for the player. If you select Zeitzunder, @{trigger_entzug} will be 2. The next time the system loads up the select dropdown, it will try to select an option with a value that matches @{trigger_entzug}. I'm not sure if the system will go to the first match or the last match, but either way, the displayed value won't be Zeitzunder despite the fact that's what the player actually selected. Instead, you could do something like this: <select name="attr_trigger_entzug_name"> <option value="Befehl">Befehl</option> <option value="Kontakt">Kontakt</option> <option value="Zeitzünder">Zeitzünder</option> <option value="Ver. Befehl">Ver. Befehl</option> <option value="Ver. Kontakt">Ver. Kontakt</option> <option value="Ver. Kontakt Geschlecht/Metatyp">Ver. Kontakt Geschlecht/Metatyp</option> </select> <input type="hidden" name="attr_trigger_entzug"> <script type="text/worker"> on('change:repeating_my_repeating_section_name:trigger_entzug_name', function() { getAttrs(['trigger_entzug_name'], function(values) { switch(values.trigger_entzug_name) { case 'Befehl: case 'Zeitzünder': case 'Ver. Befehl': setAttrs({ trigger_entzug: 2 }); break; case 'Kontakt': case 'Ver. Kontakt': setAttrs({ trigger_entzug: 1 }); break; case 'Ver. Kontakt Geschlecht/Metatyp': setAttrs({ trigger_entzug: 3 }); break; } }); }); </script> The select would work properly, @{trigger_entzug} would be the correct numeric value, and @{trigger_entzug_name} would be the name of the label.
1447804572
The Aaron
Roll20 Production Team
API Scripter
(Moving to Character Sheets)
THis is awesome, Brian.  I will be running home to check this out tonight and see where I can use it.  I remember despreately wanting this ability...but have gotten used to not having it.   Okay, not running home.  Closer to driving causally, and then walking with a slight swagger.
Thank you Brian, but this will work only on the dev server until the sheet workers come to production right? I know it might sound like a silly question :D
1447875619
Lithl
Pro
Sheet Author
API Scripter
Wandler said: Thank you Brian, but this will work only on the dev server until the sheet workers come to production right? I know it might sound like a silly question :D Correct. Worker scripts currently only function on dev.