Changing dropdown default when value-changed of another field

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing dropdown default when value-changed of another field

andi22
I was trying in my form to change the default of the dropdown when you change the value of other field, this value is set by metadata. When an ID starts with X is type1ID if not it is type2ID. I tried to put in changed value and in initial value of the dropdown this:

if( starts-with(ID, 'X'))
then 'type1ID'
else 'type2ID'

This changed the value of the dropdown but then I can't acces to the other options. There's a way to change the default value, being accesible also?
Reply | Threaded
Open this post in threaded view
|

Re: Changing dropdown default when value-changed of another field

Erik Bruchez
Administrator
What do you call the dropdown default? Can you provide a more complete example?

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Changing dropdown default when value-changed of another field

andi22
The dropdown default I mean the default option that appear, for example, in the dropdown control, my dropdown options are:
 - Type1ID.
 - Type2ID.
 - Type3ID.
 - Others
and the default option is Select.

Thanks for the reply
Reply | Threaded
Open this post in threaded view
|

Re: Changing dropdown default when value-changed of another field

Alessandro  Vernet
Administrator
So you're talking of setting the selected value, right? I.e. as if the user selected it by clicking on the dropdown. You can make the value of the dropdown a calculated value, but then it would become read-only so users wouldn't be able to change it. However, within Form Builder, you can't set the value of a field when the value of another field changes; for this you would have to edit the form, and write that logic in XForms.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Changing dropdown default when value-changed of another field

andi22
Hi, thanks for the response btw. Could that logic in xform select the value of the dropdown and the dropdown options will still be choosable or it will read-only also?
Reply | Threaded
Open this post in threaded view
|

Re: Changing dropdown default when value-changed of another field

Alessandro  Vernet
Administrator
If you write the logic in XForms that sets the value of the dropdown responding to some event, then the dropdown can be read-write (it doesn't need to be readonly).

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet