# Reading from a dropdown generated dynamically

**URL:** <https://community.plotly.com/t/reading-from-a-dropdown-generated-dynamically/39702>\
**Category:** Dash Python\
**Created:** [May 18, 2020, 10:05pm UTC](https://community.plotly.com/t/reading-from-a-dropdown-generated-dynamically/39702 "2020-05-18T22:05:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignacio.arraiz](https://avatars.discourse-cdn.com/v4/letter/i/b19c9b/32.png) [@ignacio.arraiz](https://community.plotly.com/u/ignacio.arraiz)\
**Post date:** [May 18, 2020, 10:05pm UTC](https://community.plotly.com/t/reading-from-a-dropdown-generated-dynamically/39702/1 "2020-05-18T22:05:58Z")

</div>

Hello,

I am trying to create an interactive dashboard, that shows different graphics depending on the user selection.

The idea is to have a first dropdown, and depending on the selection that the user show another dropdown. Based on the selection done on the second dropdown, I want to display one graph or another.

- First dropdown: id = “selection\_1”
- Second dropdown (dynamically generated): id = “output\_1”
- Graph output: id = “output\_1\_1”

My problem is that I do not know how to pass the user selection of the second dropdown to the second callback, and my code is not working (i did not include the graph code to make it simpler to read)

This is my code:

app.layout = html.Div(children=[  
html.Div([  
dcc.Dropdown(  
id=‘selection\_1’,  
options =[  
{‘label’: ‘Display airports network in map’, ‘value’: 0},  
{‘label’: ‘Others’, ‘value’: ‘1’},  
],  
#value = ‘1’ ## default value  
),  
],  
),

```
    html.Div(id='output_1'),
    
    html.Div(id='output_1_1'),

```

])

@app.callback (  
Output(‘output\_1’,‘children’),  
[Input(‘selection\_1’,‘value’)]  
)

def first\_selection (selected):  
if selected == 0:  
Div = html.Div([

```
            html.Div([               
                'Select what network you want to display:'                   
                ],
                style = {'width':'20%', 'marginLeft':'10px','display':'inline-block'}
                ),
            
            html.Div([
                dcc.Dropdown(
                 id='dropdown_2',
                 options=[{'label': 'Complete network', 'value': 0},
                          {'label': 'Select component to display', 'value': 1},
                 placeholder='Select the dataset...',
                 )       
                ],
                style = {'width':'20%','marginTop':'10px', 'display':'inline-block'}
                )
            ],
        ),
    return Div
else:
    return None

```

@app.callback (  
Output(‘output\_1\_1’,‘children’),  
[Input(‘selection\_1’,‘value’),  
Input(‘output\_1’,‘value’)]  
)

def plot\_whole\_network (selection\_1,selection\_2):  
if (selection\_1 == 0) and (selection\_2 == 0):  
‘’ Write here to return one grahp  
return Graph  
else:  
‘’ Write here to return another graph  
return Graph

Thank you very much,
