Answer the question
In order to leave comments, you need to log in
How to properly store and process data in JS?
I am writing a calculator on the landing page. JS is not very strong in knowledge.
When selecting dropdown items, our final combo should pull data with name, cost value, and text. How to arrange the storage and output of this data? It only comes to mind to sort through all the combinations through the conditions, but in my opinion this is clearly something from the Hindu. It is advisable to give an answer with a small example, thanks!
Answer the question
In order to leave comments, you need to log in
For example, you have a select:
<select>
<option value="dsp">ДСП</option>
<option value="lmdf">ЛМДФ</option>
</select>
var type_price = {
dsp: 10,
lmdf: 20
};
var val = select.value; // например "dsp"
var current_price = type_price[val];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question