I have a set of items that get saved but I\'m trying to change a value after I retrieve it and before I pass it of to my php function. Is it possible to change just one item?>
Try this
var args = window.localStorage.getItem("localusers");
args["type"] = 6;
//Update the localStorage with new value
localStorage.setItem("localusers", JSON.stringify(args));
Like other JavaScript
objects, you can treat the localStorage
object as an associative array. Instead of using the getItem()
and setItem()
methods, you can simply use square brackets.
var args = localStorage["localusers"];
args["type"] = 6;
//Update the localStorage with new value
localStorage["localusers"] = args;