TUIK droplist - how can you set the default selected value?

I’m a big fan of the TUIK components - just wish they were better documented.

How can I set the default selected value in a droplist? I’m able to pass a table dat to the input and have it render the list of options.

Hey,

while there is no direct function to set the default value, the eventual output is saved in a Text DAT called “string” on the inside of the droplist.

So there are 2 options to go about this. First there is a little script which lets you set the currently selected value by running:

# execute the script called 'set' inside the droplist and pass
# the row of the value you want it to be set to as an argument
# (row nr. 5 in this example)
op('droplist/set').run(5)

Otherwise you could also set the string directly:

op('droplist/string').text = 'my default selection'

Cheers
Markus