Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Store checkbox value if tick

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!

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Store checkbox value if tick

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

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Store checkbox value if tick

Hi,

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Store checkbox value if tick

Hello!

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

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Store checkbox value if tick

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

Rui Song Chong
Posts: 0
Joined: Sat Jan 17, 2015 10:51 am

Store checkbox value if tick

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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Store checkbox value if tick

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

Return to “Issues”