Dynamic number of inputs and varying id's

Hi, I’m very new to Dash and have been playing around with a project. The objective of the code is as follows:

  1. Create a dropdown of different options, for example (container1, container2, container3)

  2. Based on the choice of option (or container), the first callback then generates a number of box input components, with the number of inputs available depending on the choice of container.
    The number of inputs is predefined for each container. For example, container1 has 3 inputs, container2 has 5 inputs, etc. Each input has it’s own unique ID, ex: rope, string, pencil, etc.

  3. The second callback will dynamically update the information displayed on the dashboard based on the choice of container and corresponding inputs.

I have completed the first 2 steps. I am able to display the inputs for the containers after selecting a particular container from the dropdown. However I am struggling with linking back the input boxes with dynamically updating the dashboard.

I need to take a list of input box ids (rope, string, pencil, etc) as an input to the call back function. However the actual ids depend on the choice of container, therefore I cannot hardcode these in as I don’t know which container I will choose. I feel like I need to have a dynamic list in the input of the next callback. How can I get past this issue?

A kinda hacky way would be to already have all the input components hardcoded in your layout and to set their display to none. Then the dropdown function plays with the style to display or not the inputs you want, and your final function takes all the inputs into account, checks which ones are filled and generates your output.

Would love to hear simpler solutions

with the number of containers >100 hardcoding definitely isnt an option unfortunately

@chriddyp I was wondering if you had any ideas. I would greatly appreciate your opinion :slight_smile: