Storage
Hi
So I dont understand the "local storage" idea. My app do not require a login but there are some checkboxes that i want to store for that user.
Will local storage do the job?
Thank you
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Hi
So I dont understand the "local storage" idea. My app do not require a login but there are some checkboxes that i want to store for that user.
Will local storage do the job?
Thank you
Hi Johnny,
Yes, but please please take into account that localStorage stores strings only. That is, you can store "0" and "1" as strings.
The following discussion may be helpful for work with checkboxes: https://getsatisfaction.com/apperyio/...
Thank you yes I saw the little that I read that they also say that. Thank you again!
can I use this code below in a app? I dont get it to work. Sorry for dumb question!
Checkbox 1
Checkbox 2
Checkbox 3
Checkbox 4
Checkbox 5
SAVE
LOAD
var i, checkboxes = document.querySelectorAll('input[type=checkbox]');
function save() {
for (i = 0; i < checkboxes.length; i++) {
localStorage.setItem(checkboxes.value, checkboxes.checked);
}
}
function load_() {
for (i = 0; i < checkboxes.length; i++) {
checkboxes.checked = localStorage.getItem(checkboxes.value) === 'true' ? true:false;
}
}
http://jsfiddle.net/sQuEy/4/
Sorry the code I paste did not show but it is on the link
Hello! You can use < code tag to post your code. You would also need to explain in more details where do you use this code, what are you trying to acheive and what exactly doesn't work?
http://docs.appery.io/getting-help/
ok, i still want to do just a simple save and load on the app. Save a checkboxs value and get it when the app is loading. This is my first app and just starting to get use to the all the java script.
Your code saves checkboxed on all loaded screens and uses checkbox value for localStorage variable name (there might be problem if checkbox values are the same). To save use the following code:
codevar checked = [];
Appery("mobilecheckboxgroupName").find("input:checked").each(function(){
checked.push($(this).attr("id"));
});
localStorage.setItem("mobilecheckboxgroupName_checked", JSON.stringify(checked));/code
to get:
codevar checked, i, len;
Appery("mobilecheckboxgroupName").find("input").each(function () {$(this).prop("checked", false);});
try {
checked = JSON.parse(localStorage.getItem("mobilecheckboxgroupName_checked"));
if ({}.toString.call(checked) !== "[object Array]") {
checked = [];
}
} catch ( e ) {
checked = [];
}
for (i = 0, len = checked.length; i < len; i++) {
try {
$("#" + checked).prop("checked", true);
} catch ( e ) {
}
}
Appery("mobilecheckboxgroupName").find("input").each(function () {$(this).checkboxradio("refresh");});/code
where mobilecheckboxgroupName - mobilecheckboxgroup name
Wow thank you so much!! I really appreciate the help!
Just some feedback! The code is working beautifully thank you for the help!