Guys, hello everyone. There is a small site on which I want to make a calculator. The problem is that the calculator will consist of several stages:

  1. Select box type
  2. The choice of box size (depends on the type of box, i.e. each type has its own dimensions)
  3. The choice of filling (Depends on the size of the box, for each size of its content)

And so on, only 6-7 stages. The problem is that I really don't want to write a huge function containing only "if - else if". I thought to do the following: make a JSON file that will store all the information, and from there it will be parsed through js. Here are only torment me with doubts, am I doing the right thing? Or is there a more rational way?

The simplest thing I thought to do was create divs that I would open and hide, depending on what the user chooses. But then it turns out that you need to create a lot of divs, which can have a bad effect on the site loading, and this is not good.

Tell me, please, what is more correct to choose in this case? Thank you in advance! :)

  • Sounds like some kind of roulette. The simplest solution and the most obvious - use the database and when selecting the "box", load the data you need. - Bim Bam
  • Hello and to you. You do not give any numerical characteristics, so it is difficult to say how it will work. For example, "so many divs" - how many approximately - one hundred, one thousand, ten thousand? - a-bobkov
  • @ a-bobkov thanks for the answer!) About the data: If you store each option in a separate div, you will get about 15-20 divs. Approximate data type in JSON, which will need to be gradually output - jsfiddle.net/Alexxosipov/9nnszke8 - Alexxosipov
  • @Alexxosipov In my opinion, 15-20 divs will in no way affect the page loading speed and it’s better to immediately generate them and show-hide them as needed. - a-bobkov

0