Home > Software design >  select dynamics - reactjs
select dynamics - reactjs

Time:09-26

I have an input that generates dynamic select, when placing a value in the input this dynamically adds a select with those amounts of values, for example if the value in the input is 4 in the select it loads me the numbers from 1 to 4 and if I select a value in that select, for example, 2 loads me another select with the numbers from 3 to 4 and so on until reaching the value of 4, it also has a condition that if the highest number is chosen in the first select It would be 4 in this example, it does not generate any additional statements.

Now what I need is that the statements are not generated automatically, as it is doing, is that there is a button for each select and when giving it there is if it generates the other select.

https://codesandbox.io/s/frosty-dawn-c55ux?file=/src/App.js

CodePudding user response:

If I understood correctly, I would add a button from onClick right next to the generated select.

Instead of putting a function on onChange, put it on this new button on onClick.

CodePudding user response:

Here is an example, you initialize the max number in the input then the first Select will be generated.

https://codesandbox.io/s/stack-select-forked-qn212?file=/src/App.js

  • Related