# How to achieve the number of inputs is determined dynamically by callback

**URL:** <https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204>\
**Category:** Dash Python\
**Created:** [November 29, 2018, 11:46am UTC](https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204 "2018-11-29T11:46:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sylvos](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@Sylvos](https://community.plotly.com/u/Sylvos)\
**Post date:** [November 29, 2018, 11:46am UTC](https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204/1 "2018-11-29T11:46:08Z")

</div>

@app.callback(Output(‘output’, ‘children’),  
[Input(f’btn{i}’,‘n\_clicks’) for i in range(n)])  
def output(\*args):  
pass

the **n** is determined by length of dcc.Store(‘store’,‘data’)'s data  
How to achieve it,Thank you very much!

---

<div class="post-metadata">

**Author:** ![Sylvos](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@Sylvos](https://community.plotly.com/u/Sylvos)\
**Post date:** [November 30, 2018, 12:47am UTC](https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204/2 "2018-11-30T00:47:40Z")

</div>

@chriddyp,@Philippe  
Can you help me,thank you very much!

---

<div class="post-metadata">

**Author:** ![Philippe](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/philippe/32/3521_2.png) [@Philippe](https://community.plotly.com/u/Philippe)\
**Post date:** [November 30, 2018, 1:02am UTC](https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204/3 "2018-11-30T01:02:42Z")

</div>

Take the `n_click_timestamp` props instead for the inputs. Then find the highest one in args and do `args.index(highest)`, you now have your btn id.

---

<div class="post-metadata">

**Author:** ![Sylvos](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@Sylvos](https://community.plotly.com/u/Sylvos)\
**Post date:** [November 30, 2018, 2:48am UTC](https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204/4 "2018-11-30T02:48:45Z")

</div>

thank you @Philippe  
Like example：[Input(f’btn{i}’,‘n\_clicks’) for i in range( **n** )]，  
button id is undefined，determined by **n** ,  
and **n** is determined by length of dcc.Store(‘store’,‘data’)'s data

My difficulty is can not get **n** ，it is not a global variable，but a local variable  
it is length of dcc.Store(‘store’,‘data’)'s data

---

<div class="post-metadata">

**Author:** ![mgutijae1](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@mgutijae1](https://community.plotly.com/u/mgutijae1)\
**Post date:** [May 9, 2019, 6:10am UTC](https://community.plotly.com/t/how-to-achieve-the-number-of-inputs-is-determined-dynamically-by-callback/16204/5 "2019-05-09T06:10:32Z")

</div>

Did you find any solution?? I have a similar problem. Thanks!
