Hey Guys,
I have 2 input textbox for username and password. And one picklist for some value. Now I want a user to add these values and I am trying to save those values using chrome storage API.
Now each time I am storing a variable as how many records added like counter.
for storing I am just using like this
var skillsSelect = document.getElementById("orgTypeId");
var selectedOrgType = skillsSelect.options[skillsSelect.selectedIndex].value;
var countTotalRecords = totalRecordsVal +1;
var username = 'username'+countTotalRecords;
var password = 'password'+countTotalRecords;
var orgType = 'orgType'+countTotalRecords;
chrome.storage.sync.set({
username: $("#usernameid").val(),
password: $("#passwordid").val(),
orgType: selectedOrgType,
'totalRecords':countTotalRecords
}, function(){
alert('Success!');
});
AND for retrieving I am trying like this way
var getItems = [];
for(var i = 1; i <10; i++){
var username = 'username'+i;
var password = 'password'+i;
var orgType = 'orgType'+i;
getItems.push(username);
getItems.push(password);
getItems.push(orgType);
}
console.log('==========getItems======',getItems);
chrome.storage.sync.get(getItems, function(items){
var keys = Object.keys(items);
for (var i = 0, end = keys.length; i < end; i++) {
var key = keys[i];
console.debug(key + ' = ' + items[key]);
}
console.log('------------data---',data);
});
But I am not getting all the stored values. even I am not getting all the values in console log.