Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Unable to store radio button value in localStorage Reply To: Unable to store radio button value in localStorage

#245988
Alex Zaworski
Participant

I think this is what’s causing your problem:

$.each($('.stored'), function() {
  if(localStorage[$(this).attr('name')]) {
    $(this).val(localStorage[$(this).attr('name')]);
  }
});

Since all of your radio inputs (correctly) have the same name, this is causing each of them to be set to the same value. Here’s a dev tools screenshot showing the issue:

Radio button issue demo