Can you please tell me how to change the values of divs depending on the select?
And then when the button is clicked, check whether the fields are filled with a certain selected div.
That is, if select is selected with a value of 1, a div with id 1 appears below, and when a button with id btn_save is pressed, it checks whether the field with id user1 is filled.
For select with value 2, a div with id 2 appears below, and when a button with id btn_save is pressed, it checks if the field with id user2 is filled.
Etc.
<select id="selects">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<!-- DIVs -->
<div id="boxes">
<div id="1">
<p>1 ...</p>
<p><input id="user1"></p>
</div>
<div id="2">
<p>4 ...</p>
<input id="user2">
</div>
<div id="3">
<p>3 ...</p>
<input id="user3">
</div>
</div>
<button type="button" id="btn_save">Подтвердить</button>
2
Answers
Here is a version using recommended event listeners
Note I use hidden on each div and I changed the ID from numeric. It is not recommended to have numeric IDs since they cannot be easily accessed by CSS