Change value of dcc.Input with a callback

Hey guys,

Is it possible to update the ‘value’ parameter of a ‘dcc.Input’ object?
Some of the things I’ve tried:

app.layout = html.Div([
    dcc.Dropdown(id='selector', value='1', options= [{'label': i, 'value': i} for i in [1,2,3]]),
    dcc.Input(id='test', )

@app.callback(dash.dependencies.Output('test', 'value'),
              [dash.dependencies.Input('selector', 'value')])
def update_shocks(value):
    return value

I would like to fill several Input objects starting values based on a dropdown.

This is possible, but if you include a dcc.Input element in your layout, you also need to include a callback that has this element as either a State or an Input. (I’m presuming you’ll be hooking it up at some point anyway?)

This is covered in the Dash Gotchas section, but it’s definitely a more subtle of the gotchas.

1 Like

@nedned Thanks, that fixes it!

1 Like