Page 1 of 1

Store checkbox value if tick

Posted: Tue Feb 03, 2015 10:11 am
by Rui Song Chong

Hi,

I have multiples checkbox in one checkboxgroup, and I'm trying to get the value of each checkbox if that checkbox is ticked. Is there a simple way to accomplish this?
What I have in mind is to store the checkbox value if it is tick, into the an array in local storage. How can I do that?

Thanks!


Store checkbox value if tick

Posted: Tue Feb 03, 2015 11:12 am
by Evgene Karachevtsev

Hello Rui,

The next line finds ticked checkboxes for your component mobilecheckbox_41 name
pre$("[name=mobilecheckbox_41] input:checked").each(function(index, elem){

});/pre


Store checkbox value if tick

Posted: Tue Feb 03, 2015 11:15 am
by Rui Song Chong

Hi,

Thanks for the respond, so after I find the ticked checkboxes, how can I store them into an array in the local storage?


Store checkbox value if tick

Posted: Wed Feb 04, 2015 6:43 am
by Maryna Brodina

Hello!

Here you can find how to set a LSV from an array.
http://blog.bismallion.com/map-appery...


Store checkbox value if tick

Posted: Wed Feb 04, 2015 8:47 am
by Rui Song Chong

Hi,

Thanks for the link, however I have another problem. The checkbox I have is a loop link to the database, which has multiple rows base on the database. So now, I wish to display on the listview for each and every checkbox item name, but I'm only able to store the first checkbox item name in the local storage. Please advise, thanks!

var name_arr = [];
checkboxgroup = $('[name="checkboxgroup"]');
for (var i = 0; i < checkboxgroup.length-1; i++) {
name_arr = {"name":Apperyio("checkbox").find('input[type="checkbox"]').val() , "value":Apperyio("checkbox").find('input[type="checkbox"]').val()};
}
Apperyio.storage.nameArray.set(name_arr);

Image

Image


Store checkbox value if tick

Posted: Wed Feb 04, 2015 9:33 am
by Rui Song Chong

Put it simple, how can I know the get the second and third checkbox value if my checkbox is created using loop?


Store checkbox value if tick

Posted: Thu Feb 05, 2015 1:12 pm
by Evgene Karachevtsev

Rui,

pre$("[name=mobilecheckboxgroup_40]")&#46;each(function(index,elem){
if (index == 0) {
console&#46;log("First element");
}
if (index == 1) {
console&#46;log("Second element");
}
console&#46;log(index);

});/pre