Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Page Navigation Based On Multiple Check Boxes

Avatar

Former Community Member

Hello,

I have 3 check boxes that when checked, show different pages of the form that are hidden until checked. I have a button that, when clicked should navigate to the first page of the visible pages, but it doesn't work. So, if two of the boxes are checked, I want the button to navigate to the page of the first check box.

My question is, how do you write an if statement that has multiple variables?

I have tried the following, but neither of them work:

if (field1.presence = "1") && (field2.presence == "0") && (field3.presence == "0"))
{xfa.host.currentPage = 2;}

if (field1.presence = "1") || (field2.presence == "0") || (field3.presence == "0"))
{xfa.host.currentPage = 2;}

Any insight would be greatly appreciated.

9 Replies

Avatar

Level 7

I think all you're missing is a "==" (double equals) on your field1 presence check. You've also got an extra ")" at the end of your if statement and you don't need the quotes around the values. Give this one a try, all I did was add the extra = and delete the extra ).

if (field1.presence == 1) || (field2.presence == 0) || (field3.presence ==  0)
{xfa.host.currentPage = 2;}

Is the button click taking them several pages down the form? If it's only taking them to the next page in order, it might be simpler just to let the user scroll down on his/her own.

Avatar

Former Community Member

Any comparison always requires a double equal sign ....field1 needs a double equal.

Paul

Avatar

Former Community Member

So, I have:

if

((field1.presence == 1) || (field2.presence == 0) || (field3.presence == 0))

{xfa.host.currentPage

= 2;}

...and it still doesn't navigate. I have the code in the click event. Is the proper seperator || or && for multiple conditions?

Also when I checked the script syntax, I got an error unless I put the double "(" ")" to enclose the multiple conditions to the if statement.

Depending on which selections are checked in the check boxes, it could be 1 - 3 sheets down from the original sheet.

Thanks again...

Avatar

Level 7

Just to double check, do you have javascript selected as the scripting language?

Avatar

Level 7

Could you post the form? I'll try to get it to work for you.

Avatar

Level 7

Ok, here's the correct syntax for your script:

if (WebChatChk.rawValue == 1 || EmailChk.rawValue == 0 || PhoneChk.rawValue == 0){

    xfa.host.currentPage = 2;

    }

    

Avatar

Former Community Member

Thanks! I see where the use of pipe separators comes in now instead of the &&.