I have a custom page type with two fields, StateName
and StateCode
. I would like it so that when a value is selected in either of these fields, the other field’s value changes to match.
So for example, if I select “Alabama” in the StateName
field, the value of the StateCode
field would automatically change to “AL.” Or if I select “CO” in the StateCode
field, the StateName
field would automatically change to “Colorado,” etc. Is this possible?
(I have to keep these as two separate fields, because I need to display either the state name or the state code on the front-end depending on context. Therefore, I can’t use a single field with options like AL;Alabama
because then the field only returns the value AL
and I have no way of getting the display name Alabama
).
I know Kentico has options for setting “dependent” fields, but that only appears to determine visibility – e.g. only display Field B if I select a particular value in Field A. I can’t find a way to actually change the selected value in one field based on the selected value in another field.
Two control solution seems some kind of an overkill here. You can use StateInfoProvider to get what you want.
The other way would be to use a simple drop down control and use query like that :
to get get code and display name as value separated by |