1
I am with a project and I am developing a questionnaire. Each question has five alternatives and these questions are on the same page, within divs, and within it form. Follows the code:
<form method="post" name="form" action="#" class=""> <!-- Form -->
<div class="pb-3 mt-2"> <!-- Questão 1 -->
<h4 class="titulo border-bottom">Questão 1</h4>
<p align="justify" class="my-2 mx-3">Pergunta</p>
<div class="custom-control custom-radio mx-3 border-bottom mb-1"> <!-- Primeiro imput do tipo radio -->
<input type="radio" id="customRadio1" name="customRadio" class="custom- control-input">
<label class="custom-control-label" for="customRadio1">Sim</label>
</div>
<div class="custom-control custom-radio mx-3 border-bottom mb-1"> <!-- Segundo imput do tipo radio -->
<input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio2">Não</label>
</div>
<div class="pb-3 mt-4"> <!-- Questão 2 -->
<h4 class="titulo border-bottom">Questão 2</h4>
<p align="justify" class="my-2 mx-3">Pergunta</p>
<div class="custom-control custom-radio mx-3 border-bottom mb-1"> <!-- Primeiro imput do tipo radio -->
<input type="radio" id="customRadio1" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio1">Sim</label>
</div>
<div class="custom-control custom-radio mx-3 border-bottom mb-1"> <!-- Segundo imput do tipo radio -->
<input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
<label class="custom-control-label" for="customRadio2">Não</label>
</div>
<input type="submit" name="enviar" value="Enviar" class="btn botao" style="float: right;">
</form> <!-- Fim do form -->
That way they’re willing, when the first input of the second question is marked, the first input of the first question that is marked. And so with the second one as well. It is always the first question that is being marked. I discovered that it is because of the IDs of the elements and tried to change to CLASS and continued with the problem.
How could I solve this? I would put each question as a form?
I want to send everything together at the end. I’m using the style of Forms bootstrap.
From now on, thank you very much.
The problem is in
nameof its elements. All options have the same name.– Woss
idis an Identifier and must be unique. Inputs withnamethe same if it overwrites. It would be interesting for you to start studying the basics.– fernandosavio