Insert multiple input radio buttons in a collection


#1

Hi guys, this is my problem:
I have a form of 10 questions made by radio button choices, I’d like to collect the radio button input for every question, and store the selected answers in a collection.

This is the example of my form:

<template name="madrsform">
    <fieldset>
        <legend>Question 1</legend>
        <div>
            Text for question 1
        </div>
        <input type="radio" name="q1" value="q1_opt0" required><label>0. Answer 0 to question1</label>
        <input type="radio" name="q1" value="q1_opt1"><label>1. Answer 1 to question1</label>
        <br>
    </fieldset>
    <br>
    <fieldset>        
        
        <legend>2.  Question 2</legend>
        <div>
            Text for question 2
       </div>
        <input type="radio" name="q2" value="q2_opt0" required><label>0. Answer 0 to question2</label>
        <input type="radio" name="q2" value="q2_opt1"><label>1. Answer 1 to question2</label>
        <br>
    </fieldset>
</template>

And this is how I’d like to store the data in the collection:

{{question: qX, answer: qX_optY}, [question qX+1, answer: qX+1_optZ], ...}

Could you help me?

The next step will be display the answers to the questions on a graph…