Form submission not showing multiple checkbox values

Hi, I am testing out sending a basic form using Netlify with checkbox groups to select multiple checkboxes at once. However, when the form is sent, it only ever returns the last checkbox value selected, not ALL of them.

Right now I’m using basic html5 markup for the checkboxes (with the same name attribute for them all because they are in a group). I’ve tried removing the extraneous javascript that turns the form into steps, I’ve even tried wrapping them in a fieldset, but no luck.

I am submitting the form using ajax:

$("#main #online-quote-form form").submit(function(e) {
  e.preventDefault();

  var $form = $(this);
  $.post($form.attr("action"), $form.serializeArray()).then(function() {
    $("#online-quote-form-message").html("<div>Thank you for your submission! <span>I'll get back to you soon.<a class='btn btn--small btn--success' href='javascript:history.back()'>Take me back</a></span></div>");
$('form').hide();
  });
});

Is there something I’m missing? If I need to implement a javascript-based solution, no problem, but it shouldn’t be necessary on basic form submission like this I would think, at least not according to Netlify’s form documentation.

The submission email should list ALL the checkbox values selected, not just the last one selected.

If anyone can help, I’d really appreciate it. Thanks so much!

Hi @mgenest,

Can you link to the live form and share the HTML that you’re deploying as well? We’ll need to see that to help you debug.

Hi @futuregerald

Actually, I’ve solved it by adding name="string[]" to any checkbox value group so it will return an array instead of just one value. Seems to work now.

Thanks!

2 Likes

thanks for coming back and letting us know the fix! this helps so many future users =]