10 Replies Latest reply on Mar 10, 2017 3:13 PM by CalisMoonelf

    I need to create a custom dialog box containing check boxes.

    CalisMoonelf

      I am building a form for a small medical office. The provider wants a dialog box where he can check one or more of a few very common items. The form is being built on top of an existing document that has space limitations and cannot be modified. I have found tutorials for dialog boxes that ask for some user input, but nothing with multiple check boxes that allow me to pass the data back to my main form. I know this will involve some scripting, and I'm not afraid of that, but I am still learning javascript. I also have a budget of....nothing additional except my time, so joining a website isn't an option. I'm not asking for anyone to do this for me, just nudge me in the right direction that I can figure it out.

       

      Thank you,

      CalisMoonelf

        • 1. Re: I need to create a custom dialog box containing check boxes.
          Joel_Geraci Adobe Community Professional

          Creating JavaScript Dialogs in Acrobat is non-trivial even for experienced programmers. If you're still learning JavaScript, don't jump right into the dialog code, start with something more simple so that you understand how to get and set values for fields. Also, read up on JSON, that's how the dialogs are defined. Finally, there are examples in the Acrobat JavaScript Documentation that show how to construct an dialog, look at those.

           

          That said, it's absolutely worth joining pdfscripting.com if you're going to be attempting this as a novice. Skip Starbucks for a few days and you'll have the budget for the membership.

          • 2. Re: I need to create a custom dialog box containing check boxes.
            George_Johnson MVP & Adobe Community Professional

            Here's a link to a sample document that might help: http://www.windjack.com/resources/Examples/DialogUses.pdf

             

            The last button (Control Document Processing) demonstrates a custom dialog with a number of check boxes.

            1 person found this helpful
            • 3. Re: I need to create a custom dialog box containing check boxes.
              CalisMoonelf Level 1

              I have played with that particular file for hours, and have been unable to figure out how to pass the results back to my initial document. I learned how to add boxes, change the names etc, but passing them out has eluded me.

              • 4. Re: I need to create a custom dialog box containing check boxes.
                try67 MVP & Adobe Community Professional

                Generally speaking there are two ways of doing it:

                - Define your variable before the definition of the dialog and then apply the values to them directly in the dialog's commit function, or

                - Define your variables within the dialog itself as properties of the dialog (this.myVar1, this.myVar2, etc.) and then access them from outside the dialog (myDialog1.myVar1, myDialog1.myVar2).

                I prefer the former, but both should work.

                1 person found this helpful
                • 5. Re: I need to create a custom dialog box containing check boxes.
                  CalisMoonelf Level 1

                  Joel_Geraci  wrote

                   

                  Skip Starbucks for a few days and you'll have the budget for the membership.

                  Starbucks must be a lot more expensive than I remember it from years ago. Membership is more than the weekly grocery budget for my family. LOL

                  • 6. Re: I need to create a custom dialog box containing check boxes.
                    Karl Heinz Kremer Adobe Community Professional

                    You do this by creating properties in the dialog object:

                     

                    var myDialog = {
                      variable1: "",
                      variable2: true,
                      variable3: 34,
                    
                      initialize:  ...
                    

                     

                    Just keep in mind that you have to reference these properties using the 'this." syntax (e.g. this.variable1 = 23; ). Once you return from displaying the dialog object, you can then get the value of these properties using e.g. myDialog.variable1

                     

                    Look at the script for the last button, it does actually demonstrate how data is passed from the dialog back to the script displaying the dialog.

                    1 person found this helpful
                    • 7. Re: I need to create a custom dialog box containing check boxes.
                      George_Johnson MVP & Adobe Community Professional

                      Also, note that that sample has a few problems with the sample code. There are 6 check boxes (3 with the same item_id), but the code only deals with 4 of them, so don't let that get in the way of understanding it.

                      1 person found this helpful
                      • 8. Re: I need to create a custom dialog box containing check boxes.
                        CalisMoonelf Level 1

                        George_Johnson  wrote

                         

                        Also, note that that sample has a few problems with the sample code. There are 6 check boxes (3 with the same item_id), but the code only deals with 4 of them, so don't let that get in the way of understanding it.

                        That actually is the biggest part of what confused me. It looked to me that somehow the script passed all data collectively out and I couldn't for the life of me understand why. This comment probably has helped me more than any. Thank you!

                        • 9. Re: I need to create a custom dialog box containing check boxes.
                          George_Johnson MVP & Adobe Community Professional

                          The following modifications to the script should help:

                           

                          //Acrobat JavaScript Dialog
                          //Created by DialogDesigner from WindJack Solutions
                          var FormRouting =
                          {
                          
                          
                              result:"cancel",
                              DoDialog: function(){return app.execDialog(this);},
                              bChk1:false,
                              bChk2:false,
                              bChk3:false,
                              bChk4:false,
                              bChk5:false,
                              bChk6:false,
                          
                          
                              initialize: function(dialog)
                              {
                                  var dlgInit = 
                                  {
                                          "Chk1": this.bChk1,
                                          "Chk2": this.bChk2,
                                          "Chk3": this.bChk3,
                                          "Chk4": this.bChk4,
                                          "Chk5": this.bChk5,
                                          "Chk6": this.bChk6
                                  };
                                  dialog.load(dlgInit);
                              },
                              commit: function(dialog)
                              {
                                  var oRslt = dialog.store();
                                  this.bChk1 = oRslt["Chk1"];
                                  this.bChk2 = oRslt["Chk2"];
                                  this.bChk3 = oRslt["Chk3"];
                                  this.bChk4 = oRslt["Chk4"];
                                  this.bChk5 = oRslt["Chk5"];
                                  this.bChk6 = oRslt["Chk6"];
                              },
                              description:
                              {
                                  name: "Form Routing",
                                  elements:
                                  [
                                      {
                                          type: "view",
                                          elements:
                                          [
                                              {
                                                  type: "view",
                                                  char_height: 10,
                                                  elements:
                                                  [
                                                      {
                                                          type: "static_text",
                                                          item_id: "stat",
                                                          name: "Route Form To:",
                                                          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: "Chk1",
                                                                          name: "Marketing",
                                                                      },
                                                                      {
                                                                          type: "check_box",
                                                                          item_id: "Chk2",
                                                                          name: "Sales",
                                                                      },
                                                                      {
                                                                          type: "check_box",
                                                                          item_id: "Chk3",
                                                                          name: "Accounting",
                                                                      },
                                                                  ]
                                                              },
                                                              {
                                                                  type: "view",
                                                                  char_width: 8,
                                                                  char_height: 8,
                                                                  elements:
                                                                  [
                                                                      {
                                                                          type: "check_box",
                                                                          item_id: "Chk4",
                                                                          name: "Engineering",
                                                                      },
                                                                      {
                                                                          type: "check_box",
                                                                          item_id: "Chk5",
                                                                          name: "Division HQ",
                                                                      },
                                                                      {
                                                                          type: "check_box",
                                                                          item_id: "Chk6",
                                                                          name: "Corporate",
                                                                      },
                                                                  ]
                                                              },
                                                          ]
                                                      },
                                                  ]
                                              },
                                              {
                                                  type: "ok_cancel",
                                              },
                                          ]
                                      },
                                  ]
                              }
                          };
                          
                          
                          // Example Code
                          FormRouting.bChk1 = false;
                          FormRouting.bChk2 = false;
                          FormRouting.bChk3 = false;
                          FormRouting.bChk4 = false;
                          FormRouting.bChk5 = false;
                          FormRouting.bChk6 = false;
                          
                          
                          if("ok" == FormRouting.DoDialog())
                          {
                          
                          
                              console.println("Chk1:" + FormRouting.bChk1);
                              console.println("Chk2:" + FormRouting.bChk2);
                              console.println("Chk3:" + FormRouting.bChk3);
                              console.println("Chk4:" + FormRouting.bChk4);
                              console.println("Chk5:" + FormRouting.bChk5);
                              console.println("Chk6:" + FormRouting.bChk6);
                          }
                          
                          1 person found this helpful
                          • 10. Re: I need to create a custom dialog box containing check boxes.
                            CalisMoonelf Level 1

                            George_Johnson  wrote

                            The following modifications to the script should help:

                              

                            Wow! Above and beyond. Thank you for your help.