Get Array Value From Get Method
How to get separate values of array in javascript? in one page: var c=new Array(a); (eg: a={'1','2'}) window.location='my_details.html?'+ c + '_'; and in my_details.htm
Solution 1:
decodeURIComponent() will return you a String; you need to do something like:
var delim = ",",
c = ["1", "2"];
window.location = "my_details.html?" + c.join(delim);
And then get it back out again:
var q = window.location.search,
arrayList = (q)? q.substring(1).split("_"):[],
list = [arrayList];
arr = decodeURIComponent(list).split(delim);
This will use the value of delim as the delimiter to make the Array a String. We can then use the same delimiter to split the String back into an Array. You just need to make sure delim is available in the scope of the second piece of code.
Post a Comment for "Get Array Value From Get Method"