Populating a dropdown

What I’m trying to do:
Populate a dropdown based on selection from another dropdown. My first dropdown is State. When selecting a state, the user should be able to select an option from a predetermined list of items on the second dropdown (Make and Model) based on the first dropdown (state).

What I’ve tried and what’s not working:
Tried making a Server code but could not connect it to client-side. Went ahead and put in what I want my 2nd dropdown to show directly into my Form.

Code Sample:

paste your code between

def state_dd_change(self, **event_args):
selection = self.state_dd.selected_value

if selection == 'Alabama':
    self.make_model_dd.items = ['Chevrolet Pickup (Full Size)','Ford Pickup (Full Size)','Toyota Camry','Nissan Altima','Chevrolet Impala','Honda Accord','GMC Pickup (Full Size)','Dodge Pickup (Full Size)','Ford Mustang','Ford Explorer']

elif selection == 'Alaska':
    self.make_model_dd.items = ['Chevrolet Pickup (Full Size)','Ford Pickup (Full Size)','GMC Pickup (Full Size)','Honda Civic','Honda Accord','Dodge Pickup (Full Size)','Ford Explorer','Jeep Cherokee/Grand Cherokee','Ford Pickup (Small Size)','Chevrolet Pickup (Small Size)']

elif selection == 'Arizona':
    self.make_model_dd.items = ['Honda Accord','Honda Civic','Chevrolet Pickup (Full Size)','Ford Pickup (Full Size)','Dodge Pickup (Full Size)','Nissan Altima','GMC Pickup (Full Size)','Toyota Camry','Jeep Cherokee/Grand Cherokee','Nissan Sentra']

That looks right to me, what behavior are you actually seeing?

Client-side code and Server-side code each run on completely different computers, and may be separated by thousands of miles. They do not have access to each others’ memory, much less each others’ variables.

Edit: See Server Code

It sounds like you put function state_dd_change on the Server instead of the Client. If so, then what was your purpose in doing that? What problem were you trying to solve by doing that?

This is my output

It is client-side. I am trying to populate a dropdown based on selection made in another dropdown.

Then what did you mean by

?

Thats something I tried to do but did not work.

I got it work. I have to clear out the list of the make and model dropdown like this:

def state_dd_change(self, **event_args):
self.make_model_dd.items = []
selection = self.state_dd.selected_value

if selection == 'Alabama':
    self.make_model_dd.items = ['Chevrolet Pickup (Full Size)','Ford Pickup (Full Size)','Toyota Camry','Nissan Altima','Chevrolet Impala','Honda Accord','GMC Pickup (Full Size)','Dodge Pickup (Full Size)','Ford Mustang','Ford Explorer']
elif selection == 'Alaska':
    self.make_model_dd.items = ['Chevrolet Pickup (Full Size)','Ford Pickup (Full Size)','GMC Pickup (Full Size)','Honda Civic','Honda Accord','Dodge Pickup (Full Size)','Ford Explorer','Jeep Cherokee/Grand Cherokee','Ford Pickup (Small Size)','Chevrolet Pickup (Small Size)']