1

如何将此索引数组添加nameslocalStorage. 并调用这个元素:

var name= new Array();

for( var i=0; i<results.rows.length; i++ ) {
    names[results.rows.item(i).IdTypePrestation ] = results.rows.item(i).LibellePrestation;
}

如果我改变这一行:

names[results.rows.item(i).IdTypePrestation] = results.rows.item(i).LibellePrestation;

对此:

names[i] = results.rows.item(i).LibellePrestation;

一切都好,但我需要第一行。

4

2 回答 2

0

设置为localStorage

localStorage.someArrayValue = JSON.stringify(myArray);

获取自localStorage

myArray = JSON.parse(localStorage.someArrayValue);
于 2012-12-18T15:55:55.870 回答
0

我认为您的解决方案应如下所示:

//Set names on tableau_type line of localStorage
localStorage['tableau_type'] = JSON.stringify(names);

//Get all names on tableau_type line of localStorage
var retrievedObject = JSON.parse(localStorage['tableau_type']);
$.each(retrievedObject ,function(index,element){
    alert(element);
});
于 2012-12-19T14:15:24.123 回答