4 Replies Latest reply on Apr 24, 2011 2:55 PM by Matt_Stantec

    Simple Form Text Input Help

    Matt_Stantec

      Hi.

       

      I have been trying to find info on this very simple task for days.

       

      Basically I want a dialog box that has a user input text field and an OK_CANCEL button.

       

      I then have a text form field on my pdf.

       

      I want the user to input the text into the dialog box and when the user presses OK, it fills in the text form field on the pdf.

       

      Anyone have working examples of this simple task?

       

       

      Thanks

        • 1. Re: Simple Form Text Input Help
          try67 MVP & Adobe Community Professional

          There's a built-in JavaScript method that can do just that, called app.response. This is an adjusted version of the sample code given in the reference files:

           

          var cResponse = app.response({
          cQuestion: "How are you today?",
          cTitle: "Your Health Status",
          cDefault: "Fine",
          cLabel: "Response:"
          });
          if (cResponse == null) {
          // do nothing, since the user cancelled
          } else {
          this.getField("Text1").value = cResponse;

          }

          • 2. Re: Simple Form Text Input Help
            Matt_Stantec Level 1

            Thank you.

             

            I know about app response already.

             

            I'm trying to build the dialog box that will eventually have a few more items to select, this is why I"m trying to figure out pieces of the dialog

            at a time.

             

            I have found out how to change the text field based on a list box values using a BUTTON

            // Create a list which updates a text field
            var one = this.getField("listbox");
            var two = this.getField("textlistbox");
            if (one.value == 'Reviewed') {
                two.value='Reviewed'
            } else if (one.value == 'Resubmit') {
                two.value='Resubmit'
            } else if (one.value == 'NotReviewed') {
                two.value='Not Reviewed'
            }
            

             

            Where would I place this into a dialog script?

             

             

             

            Current Full Script:

            var myDialog =
            {
                 // Event handler to initialize the list_box
                 initialize: function(dialog)
                 {
                      dialog.load({
                      "sub1":
                           {          
                           // Create a radio Check named sub1 and set up 4 choices:
                           "Reviewed": 0,
                           "Reviewed and Resubmit": 0,
                           "Not Reviewed": 1,  // currently selected item
                           "Not Accepted": 0
                           }     
                      });
                 },
                 commit: function(dialog)
                 {
                      // Retrieve the values stored in list_box sub1:
                      var elements = dialog.store();
                      
                      // Iterate through items and take actions as needed
                      for (var e in elements["sub1"])
                           // If the value is positive, it was selected:
                           if (elements["sub1"][e] > 0 )
                           {
                                // display the list value selected:
                                app.alert("You chose:\n" + e);
                                
                                // call a related function for the selection
                                rc = elements["sub1"][e];
                                ListHandler(rc);
                           }          
                 },     
                 // Dialog object descriptor (root node)
                 description:
                 {
                      name: "Custom Dialog",
                      elements:
                      [
                      {
                           type: "view",
                           align_children: "align_left",
                           elements:
                           [
                                {
                                     type: "cluster",
                                     name: "Cluster",
                                     elements:
                                     [
                                          {
                                               type: "static_text",
                                               name: "Enter Your Full Name",
                                               font: "default"
                                          },
                                          {
                                               type: "edit_text",
                                               name: "name",
                                               char_width: 21,
                                               item_id: "sub1",
                                               font: "default"
                                          },
                                          {
                                               type: "radio",
                                               item_id: "sub1",
                                               group_id: "gp1",
                                               name: "Reviewed",
                                               width: 200,
                                               height: 25     
                                          },
                                          {
                                               type: "radio",
                                               item_id: "sub1",
                                               group_id: "gp1",
                                               name: "Reviewed As Modified",
                                               width: 200,
                                               height: 25
                                          },
                                          {
                                               type: "radio",
                                               item_id: "sub1",
                                               group_id: "gp1",
                                               name: "Revise and Resubmit",
                                               width: 200,
                                               height: 25
                                          },
                                          {
                                               type: "radio",
                                               item_id: "sub1",
                                               group_id: "gp1",
                                               name: "Not Reviewed",
                                               width: 200,
                                               height: 25
                                          },
                                          {
                                               type: "button",
                                               item_id: "butnn",
                                               name: "OK"
                                          }
                                     ]
                                },
                           {
                                type: "ok_cancel"
                           }
                           ]
                      }
                      ]
                 }
            };
            
            // Function to handle the user's list selection:
            function ListHandler(rc)
            {
                 switch (rc) {
                      case 1:
                           app.alert("Reviewed");
                           break;
                      case 2:
                           app.alert("Reviewed As Modified");
                           break;
                      case 3:
                           app.alert("Revise and Resubmit");
                           break;
                      case 4:
                           app.alert("Not Reviewed");
                           break;
                      default:
                           app.alert("Invalid Selection");
                           break;
                 }
            }
            
            rc = app.execDialog(myDialog);
            
            • 3. Re: Simple Form Text Input Help
              try67 MVP & Adobe Community Professional

              It looks like it needs to be in ListHandler, but then you will have to pass the current document as a parameter to it.

              I think a better way would be to use an external variable, which will be set in the commit section of th dialog to the user's selection, and then use it outside of the dialog to set the fields' values.

              • 4. Re: Simple Form Text Input Help
                Matt_Stantec Level 1

                This will all eventually be inside a Dynamic Stamp.

                 

                On stamp insert, the dialog popups up, user enter data, into dynamic stamp, than stamp is placed.

                 

                 

                 

                What would an example be for the Listhandler I would use the pass it from the dialog to the form field?