how to store items in local Storage in jqueryMoblie

I have 4 pages like A,B,C and D. A have fruits names, B have flowers names .4 Pages flow like this

A -->C
B -->C

When i went to C through A,C have fruits names with check box,and When I Went to C through B,C have flowers names with check box.C have book Button.When we Click book button data go to D page.

What we need is When i go to (A-->C).We select 3 fruits .Next back to B and got C.We Select 2 flowers Then Click on BookOrder We need to Show totla 5 items.In D page

My problem is only how to show Last selected items..

We tried The following:

in Page C

function imagebackRedriect( ) {
var myStuffArray =[];
 var itemName;
     $('input:checked').each(function () {
              $this = $(this);
              itemName= $(this).closest('tr').children('td:eq(2)').text();
            localStorage["myStuffLocalArray"] = JSON.stringify(myStuffArray);
           sessionStorage.setItem("forAllGridItems", myStuffArray);
              TempItems = JSON.parse(localStorage["myStuffLocalArray"]);
        var GetallElements += sessionStorage.getItem("forAllGridItems");

We tried When we select checkbox Data Add to JSON or Session, but when we leave and come back to C Data Will be removed.

Please guide me



Try using JSON.parse(sessionStorage.getItem("forAllGridItems")); in the last line when you are updating the list.

I am quite not sure why you would want to use both sessionStorage and localStorage

Which ever storage option you choose to use, it's recommended by most resources that you go with localstorage.setItem("key", "value");, and remember to use JSON.stringify() when working with any data types other than strings.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.