Depending chekbox

Discussions about CSEntry
Post Reply
hamouda1987
Posts: 9
Joined: June 14th, 2016, 7:16 am

Depending chekbox

Post by hamouda1987 »

hello people ,

I have 2 checkbox with the same value in question 1 and question 2.
question 1 : chekbox :1-car1 2- car2 3-car3 4-car4
question 2 : chekbox :1-car1 2- car2 3-car3 4-car4
what i want to do is when i choose for example in the question 1 the answers 1 and 2 , in question 2 i want to see just answers 3 and 4.
It means that the 2 chekbox depends on the 1 chekbox.

Can i do that?

Thank you good people
Kind regards
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Depending chekbox

Post by Gregory Martin »

This is nontrivial, but the best way to do this is to use a dynamic valueset. You will construct the valueset, adding each value only after checking if it was selected in the first checkbox value.

See attached for an example of this. The code is below:
PROC CHECKBOX_2

preproc

    
// In this example, there are five checkbox codes in CHECKBOX_1;
    // I will create a dynamic valueset using all but the selections in CHECKBOX_1
    numeric vsCtr = 1;
    
    
do numeric ctr = 1 while ctr <= 5
    
        
string stringCode = edit("9",ctr);
        
        
// only add codes that were not found in CHECKBOX_1
        if pos(stringCode,CHECKBOX_1) = 0 then

            
// add the code, getting the label from CHECKBOX_1 value set
            vsCheckboxCodes(vsCtr) = stringCode;
            vsCheckboxLabels(vsCtr) =
getlabel(CHECKBOX_1,stringCode);
            
inc(vsCtr);
            
        
endif;
    
    
enddo;
    
    
// end the dynamic value set
    vsCheckboxCodes(vsCtr) = "";    

    
// set the dynamic value set for CHECKBOX_2
    setvalueset(CHECKBOX_2,vsCheckboxCodes,vsCheckboxLabels);
Attachments
filteredCheckbox.zip
(2.76 KiB) Downloaded 318 times
Laedry
Posts: 5
Joined: October 12th, 2016, 5:43 am

Re: Depending chekbox

Post by Laedry »

Dear Mr Gregory,

How can I doing it if the labels are in alphabetique
Post Reply