Multiple Fields with If/then

Home Forums Classic DFFS Multiple Fields with If/then

Viewing 2 reply threads
  • Author
    Posts
    • #16398
      jenjamen
      Participant

        Hi,

        I am trying to use the CustomJS feature to evaluate several fields at once rather than writing multiple rules. I am doing a similar evaluation several times in my form.

        First Eval:
        Q1/Q2 – if either question is yes, display XTab – if both are No, display YTab

        Second Eval:
        On XTab (4 yes/no questions) – if ALL questions are yes, display ZTab, otherwise, display YTab

        I tried to take some code that you had written in another post and do the First Eval, but I keep receiving an error when I try to run it.

        Thank you in advance!

        
        
        function showXTab(){
             var Q1 = getFieldValue("Q1");
             var Q2 = getFieldValue("Q2");
             if(Q1 === "Yes" || Q2 === "No"){
                spjs.dffs.toggleVisibleTab("Xtab",true);
             if(Q1 === "No" || Q2 === "Yes"){
                spjs.dffs.toggleVisibleTab("Xtab",true);
             if(Q1 === "Yes" && Q2 === "Yes"){
                spjs.dffs.toggleVisibleTab("Xtab",true);
             }else{
                spjs.dffs.toggleVisibleTab("Ytab",true);
             }
        }
        
        //Change event on drop down
        spjs.$("#dfss_Q1, #dffs_Q2").on("change",function(){
               showXTab();
        });
      • #16422
        jenjamen
        Participant

          I got there – here’s the final code I ended up with:

          
          
          function showSpreadsheet(){
              var S1a = getFieldValue("S1a");
              var S1b = getFieldValue("S1b");
              if(S1a === "Yes" || S1b === "No"){
                  spjs.dffs.toggleVisibleTab("Spreadsheet",true);
                  spjs.dffs.toggleVisibleTab("Model",false);
                  spjs.dffs.toggleSelectedTab("Spreadsheet");
              if(S1a === "No" || S1b === "Yes"){
                  spjs.dffs.toggleVisibleTab("Spreadsheet",true);
                  spjs.dffs.toggleVisibleTab("Model",false);
                  spjs.dffs.toggleSelectedTab("Spreadsheet");
              if(S1a === "Yes" && S1b === "Yes"){
          	spjs.dffs.toggleVisibleTab("Spreadsheet",true);
                  spjs.dffs.toggleVisibleTab("Model",false);
                  spjs.dffs.toggleSelectedTab("Spreadsheet");
              }else{
                  spjs.dffs.toggleVisibleTab("Spreadsheet",false);
                  spjs.dffs.toggleVisibleTab("Model",true);
                  spjs.dffs.toggleSelectedTab("Model");
              }
          }
              }
          }
          
          // Change event on dropdown
          spjs.$("#dffs_S1a", "#dffs_S1b").on("click",function(){
              showSpreadsheet();
          });
        • #16441
          Alexander Bautz
          Keymaster

            I’m glad you figured it out. I have a hard time following up on all comments in time.

            Best regards,
            Alexander

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.