I am creating multiselect dropdown menu callback function
the problem is in state the value shows for the last country selected.
like the picture last thing in country is india so only its states are showing
my code for dropdown menus is
id="control-card",
children=[
html.P("Select Country"),
dcc.Dropdown(
id="country-select",
options=[{"label": k, "value": k} for k in all_option.keys()],
value=['All'],
multi=True,
),
html.Br(),
html.P("Select State"),
dcc.Dropdown(
id="State-select",
options=[{"label": i, "value": i} for i in all_option_state.keys()],
value=['All'],
multi=True
),
my code for callback function is:
@app.callback(
dash.dependencies.Output(‘State-select’, ‘options’),
[dash.dependencies.Input(‘country-select’, ‘value’)])
def update_state_src(selected_country):
if 'All' in selected_country:
for k in selected_country:
result= [{'label': i, 'value': i} for i in all_option_state[k]]
return result
if not selected_country:
a=[]
return a
if 'All' not in selected_country:
if selected_country:
for j in selected_country:
a= [{'label': i, 'value': i} for i in all_option_state[j]]
return a