Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I store multiple check boxes with local storage
    primarykey
    data
    text
    <p>So, to be honest I am going to have a hard time explaining this so I apologize in advanced. Basically I am populating a list of checkboxes with the names of cities. using ajax. What I want to do is allow multiple checkboxes to be checked and store each checkbox value in one single key in local storage. I guess it would look something like this as an example in local storage: city: new york,Los Angeles,Miami. I have tried everything I know and I don't even know how to phrase it in google so if anyone could me that would be great. Ill post my code below. </p> <p>--This is how I am currently populating the checkbox list: </p> <p> $(document).delegate("#main", "pagecreate", function () {</p> <pre><code> var citySelect = new Array(); $.ajaxSetup({ cache: false }) $.ajax({ url: 'base_city.php', data: '', isajax: 1, dataType: 'json', success: function (data) { var $city_box = $('#city-selector'); $city_box.empty(); for (var i = 0, len = data.length; i &lt; len; i++) { $city_box.append("&lt;label for='city_select'&gt;&lt;input type='checkbox' name='city_select[]' class='citySelect' value='" + data[i].city + "'&gt;" + data[i].city + "&lt;/label&gt;"); } } }); }); </code></pre> <p> </p> <p>--This is how I am currently storing the values:</p> <pre><code>&lt;script type="text/javascript"&gt; function filterForm() { var cityNames = $('.city_select').attr('value'); localStorage.setItem("city2", JSON.stringify(cityNames)); window.location = "#main"; location.reload(); } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload