Store multiple radio button values in an array Javascript

I would like to store my test answers in an array in javascript. I created 50 questions with for loop, the user can choose between 4 radio buttons(answer). How could i store these answers in an array?


<% for(var i = 0; i < test.questions.length; i++){%>
    <div class="card">
      <div class="card-header">
        <%= test.questions[i].question%></h5>
      <ul class="list-group list-group-flush" style="padding: 10px;">
          <li class="list-group-item"><input type="radio" name="one+<%=i%>" value="a"> <%= test.answers[0].answer%></li>
          <li class="list-group-item"><input type="radio"  name="one+<%=i%>" value="b"> <%= test.answers[1].answer%></li>
          <li class="list-group-item"> <input type="radio" name="one+<%=i%>" value="c"> <%= test.answers[2].answer%></li>
          <li class="list-group-item"><input type="radio" name="one+<%=i%>" value="d"> <%= test.answers[3].answer%></li>
          <li class="list-group-item"><input type="radio" name="one+<%=i%>" value="e"> <%= test.answers[4].answer%></li>


  var arr = []
  document.getElementById("confirm").addEventListener("click", function() {
      for (let index = 0; index < 51; index++) {
      var buttonName = "one" + index
      var buttChecked = document.querySelector('[name=buttonName]:checked')
      if (buttChecked != null) {


46 thoughts on “Store multiple radio button values in an array Javascript”

  1. pharmacie rue d’argenteuil saint gratien pharmacie demanou argenteuil , pharmacie leclerc saint orens therapy ka hindi , Fluoxetina venta online, Comprar Fluoxetina medicamento. Fluoxetina en farmacia Ecuador Comprar Fluoxetina genГ©rico [url=]Fluoxetina Prozac 20 mg[/url] pharmacie delcour avignon Fluoxetina en farmacia EspaГ±a, Comprar Fluoxetina medicamento. Comprar Fluoxetina sin receta Comprar Fluoxetina genГ©rico [url=]Comprar Fluoxetina sin receta, Fluoxetina en farmacia EspaГ±a[/url] , pharmacie de l’avenue argenteuil traitement menopause , pharmacie de beaulieu sur loire. generique fucidine comprime pharmacie jeanne d’arc Barato Accutane en EspaГ±a, Comprar Accutane medicamento. Accutane en farmacia EspaГ±a Comprar Accutane genГ©rico [url=]Comprar Accutane sin receta[/url] , pharmacie brest gare. therapie cognitivo comportementale le mans, therapie comportementale et cognitive lille medicaments depression . act therapy defusion, pharmacie bordeaux depistage therapie de couple granby pharmacie de garde wavre aujourd’hui .


Leave a Comment