forms - pass multidimensional javascript array to another page -
i have multidimensional array
- [0]string
- [1]-->[0]string,[1]string,[2]string
- [2]string
- [3]string
- [4]-->[0]string,[1]string,[2]string[3]string,[4]string,[5]info
(i hope makes sense)
where [1] , [4] arrays access info myarray[4][5].
the length of nested arrays ([1] , [4]) can varry.
i use method store, calculate, , distribute data across pretty complicated form.
not data thats storred in array makes input field not sent next page when form's post method called.
i access array same way on next page on first.
thoughts:
method 1:
i figure load data hidden fields, post everything, values on second page , load themm array require on hundred hidden fields.
method 2:
i suppose use .join() concatenate whole array 1 string, load 1 input, post , , use .split(",") break up. if im not sure how handel multidimensional asspect of still able access info myarray[4][5] on page 2.
i accessing arrary javascript, values make inputs on page 1 accessed using php on page 2.
my question is there better way acomplish need or how can set method 2 metioned above?
this solved problem:
var str = json.stringify(fullinfoarray); sessionstorage.fullinfoarray = str; var newarr = json.parse(sessionstorage.fullinfoarray); alert(newarr[0][2][1]);
if possible, can use sessionstorage
store string representation of objects using json.stringify()
:
// store value sessionstorage.setitem('myvalue', json.stringify(myobject)); // retrieve value var myobject = json.parse(sessionstorage.getitem('myvalue'));
note sessionstorage
has upper limit how can stored; believe it's 2.5mb, shouldn't hit easily.
Comments
Post a Comment