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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Any comparison always requires a double equal sign ....field1 needs a double equal.
Paul
Views
Replies
Total Likes
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...
Views
Replies
Total Likes
Just to double check, do you have javascript selected as the scripting language?
Views
Replies
Total Likes
Yes.
Views
Replies
Total Likes
Could you post the form? I'll try to get it to work for you.
Views
Replies
Total Likes
Sure. Here you go...
Views
Replies
Total Likes
Ok, here's the correct syntax for your script:
if (WebChatChk.rawValue == 1 || EmailChk.rawValue == 0 || PhoneChk.rawValue == 0){
xfa.host.currentPage = 2;
}
Views
Replies
Total Likes
Thanks! I see where the use of pipe separators comes in now instead of the &&.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies