0

I've made users to enter some values in a html page:
Here is the code:

$(function() {
            $("#savesymptoms").bind(
                    "click",
                    function() {
                        var url = "notes.html?acne="
                                + encodeURIComponent($("#acne").val())
                                + "&back="
                                + encodeURIComponent($("#bloat").val());
                        window.location.href = url;
                    });
        });  

And I've added an alert like this:
alert("values passed");
But I'm not sure that this is working. I've got some 10 values to pass to another page. Above code contains only two values. Can I use arrays to pass all 10 values? I don't want to use nomenclature used in my code, i.e., individual value passing.
P.S: acne and bloat are the ids of the fields where user enters the data. notes.html is the page where I want to pass the data.

qwertymaster
  • 341
  • 1
  • 6
  • 22

1 Answers1

0

In my opinion you can use sessionStorage in HTML5

For setting a value

sessionStorage.setItem('name', 'value');

For getting the value:

sessionStorage.getItem('name');

if you want to store the value permanently use localStorage.

Since you have almost 10 values push all those values in a JSON and store it either in sessionStorage/localStorage. You can retrieve it else where and use as per your wish

Note:values stored will be in the form of string even if you push it as JSON.You will have to make it to JSON using Jquery functions

Alternative

You can store it as window.name But this will be only valid till the window lasts/tab closed(same as sessionStorage)

Sunil Hari
  • 1,716
  • 1
  • 12
  • 20
  • This is good one, but I just want to pass the data from a page to `notes.html` page. After passing the data to `notes.html`, I'll save it in localstorage. – qwertymaster Dec 29 '14 at 13:35
  • I want to pass the data as shown in this link: http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter. My plan is to store the values after passing the data, `not storing and passing` – qwertymaster Dec 29 '14 at 13:45