# Distinguish inputs on callback

**URL:** <https://community.plotly.com/t/distinguish-inputs-on-callback/18964>\
**Category:** Dash Python\
**Created:** [February 3, 2019, 7:23pm UTC](https://community.plotly.com/t/distinguish-inputs-on-callback/18964 "2019-02-03T19:23:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clstaudt](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@clstaudt](https://community.plotly.com/u/clstaudt)\
**Post date:** [February 3, 2019, 7:23pm UTC](https://community.plotly.com/t/distinguish-inputs-on-callback/18964/1 "2019-02-03T19:23:42Z")

</div>

An output can have only one callback. Consider the following callback that is supposed to switch the content of a div on the click of a button. I would like two buttons to control the area content. I know that the callback can have multiple inputs, but how can I distinguish which buttons have been clicked if I only have the `n_clicks` property?

```
@app.callback(
    Output('div', 'children'),
    [
        Input('button-1', 'n_clicks'),
        Input('button-2', 'n_clicks'),
    ]
)
def switch_area(button_1_clicks, button_2_clicks):
    ...
```

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [February 3, 2019, 9:43pm UTC](https://community.plotly.com/t/distinguish-inputs-on-callback/18964/2 "2019-02-03T21:43:54Z")

</div>

You can compare the last clicked time stamp property of the buttons.

---

<div class="post-metadata">

**Author:** ![clstaudt](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@clstaudt](https://community.plotly.com/u/clstaudt)\
**Post date:** [February 3, 2019, 10:02pm UTC](https://community.plotly.com/t/distinguish-inputs-on-callback/18964/3 "2019-02-03T22:02:01Z")

</div>

Of course - wish I had thought of it.

It’s a bit of a hack though, isn’t it? Potential new feature for Dash to make this unnecessary?

---

<div class="post-metadata">

**Author:** ![nedned](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/nedned/32/8795_2.png) [@nedned](https://community.plotly.com/u/nedned)\
**Post date:** [February 4, 2019, 1:18am UTC](https://community.plotly.com/t/distinguish-inputs-on-callback/18964/4 "2019-02-04T01:18:14Z")

</div>

Yep, it is a bit of a hack. There’s a discussion over [here](https://github.com/plotly/dash/issues/291) about a more general solution to the problem.
