Capture "value" and "date- *" of marked RadioButtons and compare them in servlet

0

I'm doing a quizz-type game using Java Web.

The ".jsp" page that "renders" the questions looks like this:

<form action="/verificar-respostas">
<input type="radio" name="opcao-q1" value="a" data-correct="d"> Resposta 1
<input type="radio" name="opcao-q1" value="b" data-correct="d"> Resposta 2
<input type="radio" name="opcao-q1" value="c" data-correct="d"> Resposta 3
<input type="radio" name="opcao-q1" value="d" data-correct="d"> Resposta 4

<input type="radio" name="opcao-q2" value="a" data-correct="b"> Resposta 1
<input type="radio" name="opcao-q2" value="b" data-correct="b"> Resposta 2
<input type="radio" name="opcao-q2" value="c" data-correct="b"> Resposta 3
<input type="radio" name="opcao-q2" value="d" data-correct="b"> Resposta 4
</form>

How can I capture the value (attribute "value") and the value of the "data-correct" attribute of all radio buttons that are selected and store them in an array. For example: "Array (value, data-correct)". My idea here is to foreach this array to compare the two variables, if the values are the same, increment +1 in the variable "punctuation", to be saved in the database after the answers are verified.

    
asked by anonymous 12.07.2018 / 14:01

0 answers