3 Replies Latest reply on Nov 1, 2012 12:33 PM by try67

    javascript custom dialog with checkbox

    nahni00

      Hi,

       

      i want to create a dialog with an input-field and a checkbox, but I can't get the value of the checkbox.

       

      Here is my code:

       

       

      var oDlg = {

              strName: "test",

              cB: "",

          initialize: function(dialog) {

              dialog.load({"usnm":this.strName,});

          },

          commit: function(dialog) {

              var data = dialog.store();

                      this.strName = data[ "usnm"];

          },

       

              checkB: function (dialog){

             

                  this.cB = "CB pressed";

                  console.println("CB fct " + this.cB);

       

              },

       

          description: {

              name: "Test Dialog",

              elements: [ {

                  type: "view",

                  elements: [

                  {

                      name : "My Text",

                      type: "static_text"

                  },

                  {

                      item_id: "usnm",

                      type: "edit_text",

                      char_width: 30

                  },

       

                  {

                                      item_id: "checkB",

                                     type: "check_box",

                                      name: "   CB Title"

                  },

                  {

                      type: "ok_cancel",

                  },

                 

              ] },

       

          ] },

      };

       

       

      if( "ok" == app.execDialog(oDlg)) {

              console.println("Name " + oDlg.strName);


             console.println("Name " + oDlg.cB);

          

      }

       

       

      The part with the checkB: function have I found in the javascript API. I thougth this function will be called if the user cklicked the checkbox

      but no output in the console is displayed.

       

      Can anyone help me?

        • 1. Re: javascript custom dialog with checkbox
          try67 MVP & Adobe Community Professional

          - You're not committing the value of the check-box.

          - A field id must be 4 characters long.

          - The method associated with the check-box is not necessary.

          • 2. Re: javascript custom dialog with checkbox
            nahni00 Level 1

            try67 schrieb:

             

            - A field id must be 4 characters long

             

            ah ok, exactly 4 characters. thanks, that was the problem. First I tried to get the value similar to the inputfield like:

             

             

            ...

                    strName: "test",

                    cBFlag: "",

                initialize: function(dialog) {

                    dialog.load({"usnm":this.strName,});

                },

                commit: function(dialog) {

                    var data = dialog.store();

                            this.strName = data[ "usnm"];

                            this.cBFlag = data[ "checkB"];

                },

            ...

                        {

                                            item_id: "checkB",

                                           type: "check_box",

                                            name: "   CB Title"

                        },

            ...

             

             

            but then I get "undefined" so I thought perhaps you can't access the value of the checkbox and tried it similar to an example in the api with the   checkB: function.

             

            The failure was the id. Thank you very much.

             

            so the code works:

             

             

             

            ...

                    strName: "test",

                    cBFlag: "",

                initialize: function(dialog) {

                    dialog.load({"usnm":this.strName,});

                },

                commit: function(dialog) {

                    var data = dialog.store();

                            this.strName = data[ "usnm"];

                            this.cBFlag = data[ "chec"];

                },

            ...

             

                        {

                                            item_id: "chec",

                                           type: "check_box",

                                            name: "   CB Title"

                        },

            ...

            • 3. Re: javascript custom dialog with checkbox
              try67 MVP & Adobe Community Professional

              I mean the item_id property of the of the check-box. Change it to "chk1",

              for example.

              And then add this code to your commit function:

              this.cB = data["chk1"];

              And remove the "checkB" function.

              If you do that, it should work fine...