Page 1 of 1

mapping values to a checkbox

Posted: Mon Jan 23, 2017 3:24 pm
by Terry Gilliver

I am trying to set checkbox values via a mapping,

This is the gui:

Image

The napping to the two checkbox groups are similar:

Image

Image

The console output:

Image

As you can see from the gui, the single value mapping for 'transmission' works, but the two value one for the 'fueltype' is not mapped.

Can you suggest what is wrong?


mapping values to a checkbox

Posted: Tue Jan 24, 2017 3:31 pm
by Terry Gilliver

I found a work around, but i am not entirely happy with it,

i removed the mapping to the checkbox group and mapped the same value to all the checkbox items 'checked' value with the following javascript:

this is the js for the fueltype 'petrol' checked mapping:
preconsole.log("get fueltype ", value);
ra = value.split(",");
console.log("ra= ",ra);

for (var fueltype in ra) {
console.log("fueltype = ", ra[fueltype]);
if (ra[fueltype]==='petrol') {
return true;
}
}
return false;/pre

Is there a better way than mapping to each separate checkbox item?


mapping values to a checkbox

Posted: Tue Jan 24, 2017 6:01 pm
by Serhii Kulibaba

Hello,

Please run a JS code below to set/unset all checkboxes from the checkboxgroup according to the variable=array of values:

pre$("[dsid=mobilecheckboxgroup_10] input").each(function(){
$(this).attr("checked", (arr.indexOf($(this).val()) != -1)).checkboxradio("refresh");
});/pre

here arr - name of the array with values of selected checkboxes