How can I combine two IF-clauses with an AND?

  • hristoph
    Asked on October 5, 2017 at 10:27 AM

    Hello!

    I would like to combine two IF-clauses with an AND. Therefore I created the two IF-clauses and chose "IF all of the IF-rules are matched".

    The result should be, that the next page is hidden (or not).

    Unfortunately if I choose the selected results, positive clause, the next page does not hide.

    Thanks for help!


    Jotform Thread 1265672 Screenshot
  • BJoanna
    Replied on October 5, 2017 at 11:40 AM

    I am not exactly sure what are you trying to achieve. What is an AND?

    Is this the form you are working on https://form.jotformeu.com/72672418481360?

    The form has 4 pages. Do you want to show the pages 2, 3 and 4 based on the options that are selected on the first page?

    If you are working on seem other form, please provide us an ID of that form. 

  • hristoph
    Replied on October 5, 2017 at 11:56 AM

    Hello Joanna!

    Thanks for your reply! Yes, that's the form I am working on.

    Exactly, I wanna show the pages based on the selection on the first page.

    If one chooses "Tax Refund" AND "Discount Code" the page three should be hidden.

    But that's not working in the way I created the logic. In SQL I use "AND" and "OR" to Combine two clauses for example.....that's what I meant.


  • BJoanna
    Replied on October 5, 2017 at 12:32 PM

    I made some test and I think that the issue is related to the Image Checkboxes widget that you are using because you have to manually enter the target value.

    However, this is possible to achieve. Please use Does Not Contain conditional state and set your conditions like this, to hide the pages that are not selected. 

    How can I combine two IF clauses with an AND? Image 1 Screenshot 20

    I should also add one more page and move the submit button to that page. 

    Here is my demo form: https://form.jotform.com/72774645579979 

    Feel free to test it and clone it

    Hope this meet what you are looking for. 

  • hristoph
    Replied on October 5, 2017 at 1:25 PM

    Thanks for our effort!


    I don't think it's related to the widget, because with the conditions where I select only one service it's working. The Problem only appears if I select two.

    You reversed the logic in your solutions. Now it's negativ. That is working when you select two services. But the same problem appears when combining two conditions.

    For example if you select "Discount Code", the logic should be:

    IF What Service would you loke to use? DOES NOT CONTAIN "Hotel Delivery"

    AND

    IF What Service would you loke to use? DOES NOT CONTAIN "Tax refund"

    Skip to page ....


    The logic should be (how I try to implement it;))

    Selected Service Action
    Discount code no Page 3 (Hotel delivery) and 4 (Tax refund)
    Hotel delivery no Page 4 (Tax refund)
    Tax refund no Page 3 (Hotel delivery)
     
    Discount code + Tax refund no Page 3 (Hotel delivery)
     
    Discount code + Hotel delivery no Page 4 (Tax refund)
     
    Hotel delivery + Tax refund Normal
     
    Discount code + Hotel delivery + Tax refund Normal

    So somehow I need to combine two clauses. I thought "IF ALL of the rules are matched" function is to do that.

  • BJoanna
    Replied on October 5, 2017 at 1:45 PM

    I am a bit confused. Based on your examples page two should always be shown, but the page two is Hotel delivery. 

    Page 1 - Shouper

    Page 2 - Hotel delivery

    Page 3 - Tax refund

    Page 4 - Summary

    Please clarify. 

  • hristoph
    Replied on October 6, 2017 at 3:28 AM

    No, page two is "Name & Email". It's shown below "Page 1", yes that's a bit confusing;)

  • Nik_C
    Replied on October 6, 2017 at 5:29 AM

    I must agree with my colleague here, the issue is that when you're using Image checkboxes and conditions, and you say "If image checkbox equals tax refund AND if image checkbox equals discount" that will not work, because of the manual inputs. So that condition could be true only if the image checkbox equals to, for example, "tax refund discount". I'm just throwing that as an example.

    So the way to go is to check one value only, meaning, the reverse logic my colleague suggested.

    So instead of the above logic, the logic could be "If the image checkbox is not equal to Hotel delivery". And that's the logic that you should use. The problem is if you really need to check if both options are checked since the logic I just provided will not ensure that.

    It is a downside of using the Image checkboxes and conditional logic.

    This, however, would be achievable with regular checkboxes. And since you can insert the images into them, you would have pretty much similar outcome when it comes to user experience and logic will work.

    And that can be done with HTML code in checkbox options:

    How can I combine two IF clauses with an AND? Image 1 Screenshot 40

    And it looks something like this:

    How can I combine two IF clauses with an AND? Image 2 Screenshot 51

    That can be adjusted further, but just as an example. Bottom line, that will allow you to use the conditional logic that you had in mind:

    How can I combine two IF clauses with an AND? Image 3 Screenshot 62

    Here is my test form: https://form.jotform.com/72782695751975

    Please check and let us know your thoughts.

    Thank you!

  • hristoph
    Replied on October 6, 2017 at 11:08 AM

    Dear Nik,

    thanks for your detailed explanation!

    I just thought ist working now with the regular checkboxes. But now I realise it's still not working correctly. Is there an option to implement a hierarchy?

    Because now it looks like that always the rule with a single condition applies and it is not checked if there is another one (with two conditions).

    For example: If I select the "Discount Code", it always jumps to the last page. Thats right, if nothing else is selected. But if I select "Dicount Code + Hotel delivery" only the Tax refund page should be hidden.

    Did I understand something wrong in your explanation?

    Actually just the "skip"-rule applies now, the others are not working anymore.

  • hristoph
    Replied on October 6, 2017 at 11:45 AM

    Furthermore I just saw that the pages numbers I can select under "Conditions" don't correspond with the ones we build. 

    Under "Build" I have the Tax refund on page 3. In the dropdown where I create the conditions it's shown on page 4.

  • BJoanna
    Replied on October 6, 2017 at 11:57 AM

    Pages 2 is still 'Hotel delivery'. Email and name fields are on the first page of the form. 

    How can I combine two IF clauses with an AND? Image 1 Screenshot 30

    You should first move the name and email fields to the second page. 

    Also, I think that you did not use the correct logic. Please check your conditions.

    How can I combine two IF clauses with an AND? Image 2 Screenshot 41

    Based on conditions 3 and 4 if you select Hotel delivery and Tax refund, those pages should be hidden, but I think that you actually want to show them if both options are selected. And condition 5 will overrule other conditions. 

  • hristoph
    Replied on October 6, 2017 at 12:30 PM

    Yes, but if you look under conditions "Email & Name" is page 2.

    Regarding the logic:

    Yes, I want to show them if both options (Hotel delivery and Tax refund) are selected. But I don't want to show both pages if just one option is selected.

    That is either possible with a hierarchy of the conditions or if the system is checking what else options are selected (like the whole equation).

    Hierarchy:

    Condition 1+2 has the highest prio, followed by 3-5.

    Check of the whole equation:

    If I select Hotel Delivery + Discount Code: Condition 1 is true, all others are false.


    But now ist getting more weird. Currently none of the conditions is working anymore, except condition 5. If I select Tax refund, the form shows me Hotel delivery on the next page. That doesn't make sense to me anymore.

  • BJoanna
    Replied on October 6, 2017 at 1:13 PM

    You are correct. It seems that one page missing. It is not shown inside of the Form Builder and on the live form, but it is shown inside of the conditions. 

    Did you created this form from scratch or did you clone it? If this is the cloned form, please provide us the original form, so that we can see if we are able to find the cause of this issue. 

    Can you please test this form and see if it is working like you expected?

    https://form.jotform.com/72784635879982 

    This form has only two conditions. 

    How can I combine two IF clauses with an AND? Image 1 Screenshot 20


    To resolve the issue with the page breaks, I deleted all page brakes from the form and I added them again to the form.

  • hristoph
    Replied on October 16, 2017 at 5:19 AM

    I created the form from scratch. I also deleted and added the page breaks...it looks good now.

    Also the two conditions. If I add one skip-rule i think it will work for us.

    Thanks for your help, Joanna!