Country/State Selector defaults

Darek Mucek asked on September 18, 2017 18:59

Hello all - I'm attempting to set the default values of our country/state selector inputs to something more default, like, "select state." I'm extremely new to this cms experience and a thorough google search has not pointed me in the right direction.

By default both are preselected to United States and Alabama, respectively. Since technically they are "filled" in the form submit properly. I'm trying to implement a way were the second field "state" has a default value or "select state".

Thanks in advance.

Correct Answer

Trevor Fayas answered on September 19, 2017 18:22

My first option is done purely through the Kentico web interface.

Here's a picture.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on September 18, 2017 19:44 (last edited on September 18, 2017 19:45)

If you click on "Advanced" on the form control settings, you should be able to check "Add (select country) record on the first position" which will give the Country a "(Select Country)" option first. The state is still going to start with alabama but at least prevents users from just hitting submit and it going through.

Otherwise you can just use the Drop Down List and bind them to a SQL statement along the lines of the below:

CountryID: Drop down, on the bottom say "Has Depending Fields" checked, set the values to a SQL:

Select null as TheValue, '(Select a country)' as TheText
UNION ALL
Select CountryID as TheValue, CountryDIsplayName as TheText
FROM CMS_Country

and for the State, set it to depend on another field, (Visible on CountryID.Value > 0)

Select null as TheValue, '(Select a state)' as TheText
UNION ALL
Select StateID as TheValue, StateDisplayName as TheText
FROM CMS_State where CountryID = {% Convert.ToInt(Fields["CountryID"], -1) %}
1 votesVote for this answer Mark as a Correct answer

Darek Mucek answered on September 19, 2017 15:53 (last edited on September 19, 2017 15:59)

Thank you Trevor, Unfortunately I don't see the options for the first solution you provided. I'll see if I can move forward with the latter.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on September 19, 2017 15:55

Sounds good, if it ends up working mark as answered, or post any other questions as you come along with them on this one.

1 votesVote for this answer Mark as a Correct answer

Darek Mucek answered on September 19, 2017 18:17

Hello again - I don't have access nor the training to technically start changing any code behind so I'm curious to know how Trevor's first suggestion can be achieved. Perhaps I'm looking in the wrong fields/settings... etc?

Thank you

0 votesVote for this answer Mark as a Correct answer

Darek Mucek answered on September 19, 2017 19:05

Ahh yes, Thank you Trevor! :) That technically answers the question.

In our situation we are utilizing the form control, "Ajax Country Selector", which defaults to United States, Alabama which isn't desired as we want our customers to select a state, not just have it default to AL.

Thank you

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.