Update Input value


#1

I have two dcc.input’s with id’s “a” and “b”. I would like to have a callback that updates b when a is changed.

I wrote the and it will not update the value…

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash(name)

app.layout = html.Div([
dcc.Input(
id=‘input-a’,
type=‘number’,
value=9,
),
html.Div(id=‘output-a’),

dcc.Input(
    id='input-b',
    type='number',
    value=9,
),
html.Div(id='output-b')

])

@app.callback(
dash.dependencies.Output(‘input-b’, ‘value’),
[dash.dependencies.Input(‘input-a’, ‘value’)])
def callback_a(dropdown_value):
print(dropdown_value)
return 8

if name == ‘main’:
app.run_server()


Unable to update dcc.Input value on callback
#2

I’ve discovered the same issue. I’m guessing there is a specific restriction regarding dcc.Input, but a brief description of why this doesn’t work would be helpful.

thanks!


#3

The issue might be that you only have one callback but two different Dash components that should be registered as inputs. See the section " All Dash Core Components in a layout should be registered with a callback." in the Dash FAQs

You should have a callback with input-b as an input.