2 Replies Latest reply on Sep 7, 2012 1:57 PM by creditunion123

    Dialogue tick boxes un-hiding all fields, not just the ones where value has changed to true

    creditunion123 Level 1

      I am hoping someone can help me make what I want to happen, happen if certain check boxes are ticked withing the dialogue box

       

      right now I can see on the console print that the tick box turns the value from false to true but the OK button is also un-hiding all my fields rather than just the ones where the value has turned to true. What am I missing here

       

       

      //Create a Dialogue box for staff to state how many of the account owners are in branch in order for the names to show in the signing section
      var Signors =
      {

          result:"cancel",
          DoDialog: function(){return app.execDialog(this);},
          bChk2:false,
          bChk3:false,
          bChk4:false,
          bChk5:false,
          initialize: function(dialog)
          {
              var dlgInit =
              {
                      "Chk2": this.bChk2,
                      "Chk3": this.bChk3,
                      "Chk4": this.bChk4,
              };
              dialog.load(dlgInit);
          },
          commit: function(dialog)
          {
              var oRslt = dialog.store();
              this.bChk2 = oRslt["Chk2"];
              this.bChk3 = oRslt["Chk3"];
              this.bChk4 = oRslt["Chk4"];
          },
          description:
          {
              name: "Signors",
              elements:
              [
                  {
                      type: "view",
                      elements:
                      [
                          {
                              type: "view",
                              char_height: 10,
                              elements:
                              [
                                  {
                                      type: "static_text",
                                      item_id: "stat",
                                      name: "Who is here to sign:",
                                      char_width: 15,
                                      alignment: "align_fill",
                                      font: "dialog",
                                  },
                                  {
                                      type: "view",
                                      char_width: 8,
                                      char_height: 8,
                                      align_children: "align_top",
                                      elements:
                                      [
                                          {
                                              type: "view",
                                              char_width: 8,
                                              char_height: 8,
                                              elements:
                                              [
                                                  {
                                                      type: "check_box",
                                                      item_id: "Chk2",
                                                      name: "Primary Applicant",
                                                  },
                                                  {
                                                      type: "check_box",
                                                      item_id: "Chk3",
                                                      name: "Associate 1",
                                                  },
                                                  {
                                                      type: "check_box",
                                                      item_id: "Chk4",
                                                      name: "Associate 2",
                                                  },
                                              ]
                                          },
                                         
                                      ]
                                  },
                              ]
                          },
                          {
                              type: "ok_cancel",
                          },
                      ]
                  },
              ]
          }
      };

      // did the value change when ticked - lets check
      Signors.bChk2 = false;
      Signors.bChk3 = false;
      Signors.bChk4 = false;
      if("ok" == Signors.DoDialog())
      {
          if (Signors.bChk2 = true)
      getField("Signor1").hidden = false;
      getField("Staff1").hidden = false;
      getField("Date1").hidden = false;
      getField("Date2").hidden = false;

      if (Signors.bChk3 = true)
      getField("Signor2").hidden = false;
      getField("Staff2").hidden = false;
      getField("Date3").hidden = false;
      getField("Date4").hidden = false;

      if (Signors.bChk4 = true)
      getField("Signor3").hidden = false;
      getField("Staff3").hidden = false;
      getField("Date5").hidden = false;
      getField("Date6").hidden = false;

          console.println("Chk2:" + Signors.bChk2);
          console.println("Chk3:" + Signors.bChk3);
          console.println("Chk4:" + Signors.bChk4);
          console.println("Chk5:" + Signors.bChk5);
      //console.println shows if bChk.. is true or false
      }
          console.println("Chk2:" + Signors.bChk2);
          console.println("Chk3:" + Signors.bChk3);
          console.println("Chk4:" + Signors.bChk4);
          console.println("Chk5:" + Signors.bChk5);
      }

      //Yeah, confirmed values have changed, now show fields based on staff input

      //was primary applicant ticked


      doWhatIWant: function(results) {
      if (results [Signors.bChk2] = true)
      getField("Signor1").hidden = false;
      getField("Staff1").hidden = false;
      getField("Date1").hidden = false;
      getField("Date2").hidden = false;

      //was Associate 1 ticked
      if (results [Signors.bChk3] = true)
      getField("Signor2").hidden = false;
      getField("Staff2").hidden = false;
      getField("Date3").hidden = false;
      getField("Date4").hidden = false;

      //was Associate 2 ticked
      if (Signors.bChk4 = true)
      getField("Signor3").hidden = false;

      if (Signors.bChk4 = true)  
      ("Staff3").hidden = false;

      if (Signors.bChk4 = true)
      ("Date5").hidden = false;

      if (Signors.bChk4 = true)
      ("Date6").hidden = false;

        • 1. Re: Dialogue tick boxes un-hiding all fields, not just the ones where value has changed to true
          George_Johnson MVP & Adobe Community Professional

          You're missing some curly brackets, using the incorrect equality operator, and using the long deprecated field.hidden property. Try this:

           

          if ("ok" == Signors.DoDialog()) {

              if (Signors.bChk2) {

                  getField("Signor1").display = display.visible;

                  getField("Staff1").display = display.visible;

                  getField("Date1").display = display.visible;

                  getField("Date2").display = display.visible;

              }

           

              if (Signors.bChk3) {

                  getField("Signor2").display = display.visible;

                  getField("Staff2").display = display.visible;

                  getField("Date3").display = display.visible;

                  getField("Date4").display = display.visible;

           

              if (Signors.bChk4) {

                  getField("Signor3").display = display.visible;

                  getField("Staff3").display = display.visible;

                  getField("Date5").display = display.visible;

                  getField("Date6").display = display.visible;

              }

           

              console.println("Chk2:" + Signors.bChk2);

              console.println("Chk3:" + Signors.bChk3);

              console.println("Chk4:" + Signors.bChk4);

              console.println("Chk5:" + Signors.bChk5);

          }

           

          I don't know if that will deal with all of the problems, but it's a good start.

          • 2. Re: Dialogue tick boxes un-hiding all fields, not just the ones where value has changed to true
            creditunion123 Level 1

            Just had to add a curly bracket at bottom of bChk3 and it worked perfectly. Thanks so much!!