Paul Medawar
Posts: 0
Joined: Thu Apr 03, 2014 10:55 am

Mapping an array to Checkboxgroup

Sorry, just noticed that the full logs were not pasted correctly

Here they are again

the following appears when I have ["2"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []

when i have ["4"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []
[Log] check box[2] =
[Log] []
[Log] check box[3] =
[Log] []

they both look and work fine...but when I have more than one number in the array, for example ["2","4"}

nothing appears in the console and none of the checkboxes are checked

Paul Medawar
Posts: 0
Joined: Thu Apr 03, 2014 10:55 am

Mapping an array to Checkboxgroup

Sorry, just noticed that the full logs were not pasted correctly

Here they are again

the following appears when I have ["2"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []

when i have ["4"] in the array

[Log] check box[0] =
[Log] [

]
[Log] check box[1] =
[Log] []
[Log] check box[2] =
[Log] []
[Log] check box[3] =
[Log] []

they both look and work fine...but when I have more than one number in the array, for example ["2","4"}

nothing appears in the console and none of the checkboxes are checked

Paul Medawar
Posts: 0
Joined: Thu Apr 03, 2014 10:55 am

Mapping an array to Checkboxgroup

Sorry just seen the log didn't paste fully...here's screenshots instead

Image

Image

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Mapping an array to Checkboxgroup

Hi Paul,

That means you don't have checkboxes with such names.

Use following JS code to log these names too:

pre

var onDelay = function(){
for(var i = 0; i < data&#46;channels; i++){
var checkBox = Apperyio("mobilecheckboxgroup_10")&#46;find('[value='+data&#46;channels+']');
console&#46;log("check box[" + i + "] with name " + data&#46;channels + " = ");
console&#46;log(checkBox);
checkBox&#46;prop('checked', true)&#46;refresh();
}
};
window&#46;setTimeout(onDelay, 100);

/pre

Regards.

Paul Medawar
Posts: 0
Joined: Thu Apr 03, 2014 10:55 am

Mapping an array to Checkboxgroup

Hi Yurii,

I found that changing

for(var i = 0; i < data.channels; i++){

to

for(var i = 0; i < 4; i++){

has allowed the response to map to the checkboxes, when there is more than one number in the array.

does this appear like an adequate solution?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Mapping an array to Checkboxgroup

Hi Paul,

It's not good to hardcore array length.

Sorry i see there was error in given before code.

here is a corrected:

pre

var onDelay = function(){
for(var i = 0; i < data&#46;channels&#46;length; i++){
var checkBox = Apperyio("mobilecheckboxgroup_10")&#46;find('[value='+data&#46;channels+']');
console&#46;log("check box[" + i + "] with name " + data&#46;channels + " = ");
console&#46;log(checkBox);
checkBox&#46;prop('checked', true)&#46;refresh();
}
};
window&#46;setTimeout(onDelay, 100);

/pre

Regards.

Paul Medawar
Posts: 0
Joined: Thu Apr 03, 2014 10:55 am

Mapping an array to Checkboxgroup

:) Thanks Yurii, great as always, and a lot of the advice you have given on other peoples questions has helped me get the most out Appery!

Not sure if you guys will be covering this in the upcoming update, but the platform keeps hanging everytime I click cancel in mapping.

thanks again for your help, and an amazing product

Return to “Issues”