Fill a text field with a preset value based on the selected value of a list in XLS Forms

I am building an xlsx form for ODK. I have a dropdown list and a text-input field. I would like when I select a value from the ListA, a specific code to be filled in the text-input field.

For example if I choose "valueA" from the dropdown list the value "codeA" to appear in the text-input. Currently I have an excel sheet with all the matches between the values in ListA and the corresponding codes (around 300). All the values in ListA are unique.

I was making some tests trying to use the "Calculation" field of Xls but no success till now. Has anyone done something like that with Xls? Is it possible?

Good morning @dkarakostis,

Welcome on the ODK Community forum, please take some time to Introduce yourself here!

This discussion may be interesting : Assigning a dynamic default value to a text-type question


Is this a value that needs to be user-editable or just displayed? If it doesn't need to be user-editable, you should be able to make text field readonly and put ${my-select} in the calculation column.

If it needs to be user-editable, see the tip section of We will hopefully soon have support for setting the value of a field when the value of another field changes in XLSForm: XLSForm proposal to calculate a value when another value changes