N
N
nastya_zholudeva2018-08-31 09:10:36
JavaScript
nastya_zholudeva, 2018-08-31 09:10:36

How to create an object in an array when a checkbox is clicked?

5b88daf2a05b3491425328.pngEach checkbox block has its own id and each checkbox has its own key. It is necessary that when a checkbox is selected, it is added to the filters array as an object {'filterId': id, 'value': ''}
. If a checkbox is unchecked, then it is removed from this array
As a result, by clicking on the "View" button, you need to get an array of objects of the selected checkboxes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-08-31
@nastya_zholudeva

Checkboxes have such attributes true-value and false-value, and put your object in them, it will be assigned to a variable.
UPD: I lied a little. You can stick an object directly into value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question