Answer the question
In order to leave comments, you need to log in
How to loop through input+textarea from each question and write everything to an array?
We have a list of questions (where there is a question itself, and two fields are an assessment and a textarea). When submitting, you need to somehow form an array so that you can then parse it in the opposite direction and understand which question is which answer.:
I suppose it should go something like this
[Question1[score:2,text:textarea],
Question2[score: 1,text:textarea]]
An example of the layout of the first question.
<label class="form-text-field">
<span class="form-text-quiz-field__label">Текст вопроса номер 1?</span>
<div class="rating-area q1">
<input id="q1-star-5" type="radio" name="q1" value="5">
<label for="q1-star-5" title="5">5</label> <input id="q1-star-4" type="radio" name="q1" value="4">
<label for="q1-star-4" title="4">4</label> <input id="q1-star-3" type="radio" name="q1" value="3">
<label for="q1-star-3" title="3">3</label> <input id="q1-star-2" type="radio" name="q1" value="2">
<label for="q1-star-2" title="2">2</label> <input id="q1-star-1" type="radio" name="q1" value="1">
<label for="q1-star-1" title="1">1</label></div>
<input placeholder="Comment" name="q1" type="textquiz" display="true" autoload="true" class="form-text-field__input"> <!----></label>
Answer the question
In order to leave comments, you need to log in
label.form-text-field
with querySelectorAll()
.[...allLabels]
map()
, forming from the next label
element of the output array with textsDidn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question