H
H
HelpSophie2019-02-07 23:58:23
JavaScript
HelpSophie, 2019-02-07 23:58:23

Where is it correct to store data in data- or json for a service calculation calculator?

What is the best way to make a calculator for calculating the cost of services?
2 questions in one:
1. data- attributes or json?
2. Is it correct to make inputs? From a semantic point of view, it seems reasonable.
Hidden input with data- attributes + label

<input class="visually-hidden" type="radio" id="id1" name="service-type"  
data-size="88" data-price-econom="150" data-price-business="200" data-installation="100">
<label> <img> услуга 1го типа</label>

Or create json directly in the js file (there are not many services, each has 6 characteristics), a separate file probably does not make sense.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WapSter, 2019-02-08
@HelpSophie

1. No difference, for a small script. And json is better, because we do less type conversion, everything is stored in one place, we drive the DOM less.
2. input for such purposes is desirable to use in fact, you can easily send data to the backend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question