How to for loop inputs in callback from other input

I’m creating input boxes base on the user’s choice.

	[Output('Symbol', 'children'),Output('Date', 'children')],
	[Input('Update_Button', 'n_clicks')],
	[State('Number_of_Event', 'value')])
def numberchoose(n_clicks, num):
        if n_clicks:
		global store
		store = num
		return ([dcc.Input(type='text', id='symbol%i' % i)for i in range(num)],
				[dcc.Input(type = 'Date',  id = 'date%i' % i) for i in range(num)])

And then use the created inputs’ value for another callback to generate plots

	Output('AR', 'figure'),
	[Input('Submit_Button', 'n_clicks')],
	[State('symbol%i' % i, 'value') for i in range(store), 
	State('date%i' % i, 'value') for i in range(store)])
def arplot(n_clicks, ?, ?):

Here is where I got stuck since I don’t know the number user would choose, what should I put in the argument. In fact, I’m not sure if the for loop would work in State.
I attached a screenshot of what the current page looks like.
Thank you

Hi @double12 and welcome to the Dash community :slight_smile:

I think Pattern-Matching Callaback will work for this use-case. See Pattern-Matching Callbacks | Dash for Python Documentation | Plotly.

Also, you may find this topic informative: “Why global variables will break your app” Part 5. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly

1 Like

Thank you, that’s very helpful