Output Checkbox Text
Checkbox variables have a value of 0 or 1. When display a checkbox value on a subject report, it is typically preferred to have the name of the checkbox. The following two examples demonstrate how to display the checkbox variable’s name when a checkbox is checked.
Example 1:
This example shows how to list checkboxes that are checked in separate lines. If no checkbox is checked, display “None.”
The following would be entered in the Script window:
var symptomList1="";
symptomList1+=outputCheckboxLine(#nausea.value.value,#nausea.definition.name);
symptomList1+=outputCheckboxLine(#headache.value.value,#headache.definition.name);
symptomList1+=outputCheckboxLine(#vomiting.value.value,#vomiting.definition.name);
symptomList1+=outputCheckboxLine(#fever.value.value,#fever.definition.name);
symptomList1+=outputCheckboxLine(#fatigue.value.value,#fatigue.definition.name);
if (isNull(symptomList1)) symptomList1="None";
function outputCheckboxLine(value,name) {
if (value==1) return (name + "<br>");
else return "";
}
The variable ‘symptomList1’ would be entered into the body of the report (see screenshots below)
Example 2:
This example shows how to list checkboxes that are checked in one line with each item separated by a comma. If no checkbox is checked, display ”None.”
The following would be entered in the Script window:
var symptomList2="";
var counter=0;
symptomList2+=outputCheckboxComma(#nausea.value.value,#nausea.definition.name);
symptomList2+=outputCheckboxComma(#headache.value.value,#headache.definition.name);
symptomList2+=outputCheckboxComma(#vomiting.value.value,#vomiting.definition.name);
symptomList2+=outputCheckboxComma(#fever.value.value,#fever.definition.name);
symptomList2+=outputCheckboxComma(#fatigue.value.value,#fatigue.definition.name);
if (isNull(symptomList2)) symptomList2="None";
function outputCheckboxComma(value,name) {
if (value!=1) return "";
counter=counter+1;
if (counter==1) return name;
else return ", " + name;
}
The variable ‘symptomList2’ would be entered into the body of the report (see screenshots)
Example of subject report output: