Page 1 of 1

Multiple Select Checkbox

Posted: October 13th, 2021, 6:00 am
by lmangcahan
Dear Team,
Would like to seek your assistance on checkbox condition. Posted below is my code to which I have problem with.
The condition wherein if poschar("23",F110) is true however, result is warning("ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM."); to which it turned out also true on 1st condition.

Thanks alot.
postproc
if pos("2",F110) then
warning("ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM.");
elseif pos("3",F110) then
warning("ACCOMPLISH CAF FORM 28 – ESTABLISHMENT REFERRAL FORM.");
skip to F114;
elseif poschar("23",F110) then
warning("PLEASE ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM AND FORM 28 – ESTABLISHMENT REFERRAL FORM.");
skip to F114;
endif;

Re: Multiple Select Checkbox

Posted: October 13th, 2021, 9:58 am
by htuser
Dear Imangcahan,
For checkbox, it's advised to not use pos or poschar to verify if a response is checked. But, you must use the isChecked function: https://www.csprousers.org/posts/2020-0 ... f-pos.html
Please change your code and, if there's a problem, post a demo app with the issue, we'll be able to help you a bit more.
Hope this help you

Re: Multiple Select Checkbox

Posted: October 13th, 2021, 11:56 am
by etuser
Dear Sir,

Here I modified your syntax and hope it works

postproc

If length(strip(F110) in 1 then

if pos("2",F110) then
warning("ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM.");
elseif pos("3",F110) then
warning("ACCOMPLISH CAF FORM 28 – ESTABLISHMENT REFERRAL FORM.");
skip to F114;
Endif;
elseif length(strip(F110) > 1 then
if pos ("23",F110) then
warning("PLEASE ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM AND FORM 28 – ESTABLISHMENT REFERRAL FORM.");
skip to F114;
endif;
Endif;

Re: Multiple Select Checkbox

Posted: October 13th, 2021, 1:57 pm
by sherrell
Dear Imangcahan,

For the reasons stipulated in the forum link shared in HTUSER's post, you'll want to use the ischecked() function.

The updated code will not help, for it means users can never select (i.e., check) more than one field--defeating the purpose of the checkbox field.

Sherrell

Re: Multiple Select Checkbox

Posted: October 14th, 2021, 4:05 am
by etuser
Dear Sherrell,

I always taught the function “Pos” and “Ischecked” yields the same result i.e. “TRUE”
if the checkbox is a single digit value labels, meaning, if the variable F110 is
1 AAA
2 BBB …..

But might gives different result "TRUE/FALSE" or 0 or 1 , if the value label is a two or more digits
01 AAA
02 BBB …

Here the variable F110 seems a single digit checkbox. The question which remain is, when the variable F110=23 .How can we get the warning message
warning("PLEASE ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM AND FORM 28 – ESTABLISHMENT REFERRAL FORM.");

because the first "if" is going to be true and the others are "else" .

Kindest Regards

Re: Multiple Select Checkbox

Posted: October 14th, 2021, 1:14 pm
by sherrell
Hi ETUser,

pos and ischecked definitely yield the same result for a single character field. However, the logic snippet showed searches for 2, 3, and 23, so there is at least one two-digit field that needs to be accounted for.

Checkboxes are intended for situations when the user can select more than one response (as in our example, how many languages do you speak). So, if the user wanted to select 2, 3, and 23, the logic you provided would fail, since in that situation the string length would be 4, and they would never be able to find the '2' and '3' responses.

However I should point out, if wishing to use the capture type checkbox for an alpha field, there are several requirements. Specifically,

- The variable (F110) must be an alpha string
- F110 must be a multiple of the # of responses provided
- Each response within F110 must be the same length (I'm using a FW of 2)
- If the responses are 2+ characters long, then they must use zeros or other visible characters to fill the string; leading or trailing spaces are not allowed

Therefore, the allowable responses would be 02, 03, and 23, and (if these were our only responses) the field length of F110 = 6. The updated logic would be:
PROC F110

   
if ischecked("23",$) then
        warning
("PLEASE ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM AND FORM 28 – ESTABLISHMENT REFERRAL FORM.");
       
skip to F114;

   
elseif ischecked("02",$) then
        warning
("ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM.");

   
elseif ischecked("03",$) then
        warning
("ACCOMPLISH CAF FORM 28 – ESTABLISHMENT REFERRAL FORM.");
       
skip to F114;
   
endif;
Thanks for writing.
Sherrell

Re: Multiple Select Checkbox

Posted: October 14th, 2021, 1:44 pm
by etuser
Many Thanks, Sherrell, Now it is clear .

Re: Multiple Select Checkbox

Posted: October 14th, 2021, 3:28 pm
by sherrell
Hi ETuser,

Actually, I was writing for the broader example--where there are numerous examples beyond the "three" choices given here--though there aren't really 3 choices, there are only 2 choices. So if this is the case, then the logic should be the following, based on F110 being an alpha of length 2, with only 2 choices possible, 2 and 3:
PROC F110

   
if ischecked("2",$) and ischecked ("3",$) then
        warning
("PLEASE ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM AND FORM 28 – ESTABLISHMENT REFERRAL FORM.");
       
skip to F114;

   
elseif ischecked("2",$) then
        warning
("ACCOMPLISH CAF FORM 29 – HOUSEHOLD REFERRAL FORM.");

   
elseif ischecked("3",$) then
        warning
("ACCOMPLISH CAF FORM 28 – ESTABLISHMENT REFERRAL FORM.");
       
skip to F114;
   
endif;
Now I think we've covered all bases!
Sherrell