12 Replies Latest reply on Apr 3, 2008 9:22 AM by Patrick Leckey

    Submit to selection

    Level 1
      Excuse the strange topic but I have a request to perform the following

      3 radio buttons in an AcroForm - the user selects one option and when SUBMIT is clicked, the form submission goes to an email address hidden behind that radio button

      i.e.

      button 1 = London
      button 2 = New York
      button 3 = Paris

      if the user selects radio button 1 it will then ensure the recipient is london@xxx.com

      Any help would be greatly appreciated.

      Using Acrobat 8

      Cheers!

      Jon

      PS - I know three submit buttons could be created but that's a little clumsy and I'm also wondering if Livecycle is the best solution but either way, a script would be required?
        • 1. Re: Submit to selection
          MarkWalsh Level 4
          For each email button, set the tooltip to the email address.

          //Add this to your document javascript:

          var emailAddress = ""

          function setEmail () {
          emailAddress = event.target.userName
          }

          function emailForm() {
          if(emailAddress == "") {
          app.alert ("You haven't selected an email address yet."};
          } else {
               this.mailDoc({
                   bUI: false,
                   cTo: emailAddress,
                   cSubject: "Enter your subject here",
                   cMsg: "Enter your email message here"
               });
          }
          }

          //Add the following to each email button mouseup:

          setEmail ()

          //Add the following to your Submit button mouseup:

          emailForm ()
          • 2. Re: Submit to selection
            Level 1
            Hi Mark,

            That's great - really appreciate your time.

            I might have described the scenario incorrectly.

            The form will have fields for the end-user to complete. As they work their way down the form, maybe halfway down they come across three radio button or a list box. Whatever their selection, when the SUBMIT button is clicked at the bottom , the form contents are then sent to the selection (email address).

            Looking to include this data inside the PDF once ARE have been enabled through the Distribute Form option under Acrobat 8 Professional.

            Let me know if this is feasible?

            Take care,

            Jon
            • 3. Re: Submit to selection
              MarkWalsh Level 4
              Sorry, for some reason, I misread your radio buttons as buttons. You can set the ExportValue of each radio button field to the email for that selection.

              Change the email function to this (I am useing the name 'myButton'. you need to change this to the name of the radio button field you are using)

              function emailForm() {
              this.mailDoc({
              bUI: false,
              cTo: this.getField("myButton").value,
              cSubject: "Enter your subject here",
              cMsg: "Enter your email message here"
              });
              }
              • 4. Re: Submit to selection
                Level 1
                Hi Mark,

                Thanks for your help

                1) do I still include the document javascript as before?

                2) I understand setting the export values to the email address inside the export value of the radio button but where does the script go? Should this be set as javascript inside radio button or in the submit form field?

                3) on that point, I would like to have people make their selection in the radio button, continue to fill-in the form and then at the bottom, once they click SUBMIT then for the PDF to be delivered to that specific email address (as per export value within the radio button)

                Prior to delivery, the PDF will have Adobe Reader Extensions applied via the Distribute Forms Workflow option in Acrobat 8 Professional.

                Can this work?

                Thanks for your help,

                Jon
                • 5. Re: Submit to selection
                  MarkWalsh Level 4
                  1) You don't need the document javascript if you put the code from the email function directly into the submit button mouseup action (without the first and last lines). I prefer putting all my code into a document javascript as functions, and only putting the call to them in the button actions (makes editing code for all buttons/fields a lot easier when it's all in one place, plus multiple fields can share the same code.)

                  2) The code to call the email function will go into the mouseup action for the submit button. The radio button shouldn't need any code. btw, below I added back in a dialog to alert the user if no email address is selected.

                  // Use this code for the Submit button mouseup action
                  var emailAddress = this.getField("City").value
                  if(emailAddress == "" || emailAddress == "Off") {
                  app.alert ("You haven't selected an email address yet.");
                  } else {
                  this.mailDoc({
                  bUI: false,
                  cTo: emailAddress,
                  cSubject: "Enter your subject here",
                  cMsg: "Enter your email message here"
                  });
                  }

                  /////// OR ////////

                  // Use this code for the Submit button mouseup action
                  sendEmail()

                  // And put this code into the document Javascript
                  function sendEmail() {
                  var emailAddress = this.getField("City").value
                  if(emailAddress == "" || emailAddress == "Off") {
                  app.alert ("You haven't selected an email address yet.");
                  } else {
                  this.mailDoc({
                  bUI: false,
                  cTo: emailAddress,
                  cSubject: "Enter your subject here",
                  cMsg: "Enter your email message here"
                  });
                  }
                  }
                  • 6. Re: Submit to selection
                    Level 1
                    Mark,

                    That worked a bloody treat - thank you so much!

                    I really appreciate your time - good things these forums (especially the people in them) ;-)

                    Cheers,

                    Jon
                    • 7. Re: Submit to selection
                      Level 1
                      Hi Mark,

                      You're going smile at this one - any idea how to get working with XFA forms in Livecycle Designer 7? They love the functionality but after now seeing Livecycle Designer - they feel it's a more productive environment and I have to agree.

                      The javascript is being recompiled to the XFA model and it all looks a little alien since I'm not a scripter?

                      Do you know javascriot within Livecycle? Any help would be gratefully received.

                      All the best,

                      Jon
                      • 8. Re: Submit to selection
                        Patrick Leckey Level 3
                        For your above code:<br /><br />this.getField() can be replaced with xfa.resolveNode()<br /><br />any other occurrences of this.<anything> can be replaced with:<br /><br />var myDoc = event.target;  // You only need to declare this once per event<br />myDoc.<anything>;<br /><br />This is specific to your code above and should not be considered a global solution to porting AcroForms JS to XFA JS.
                        • 9. Re: Submit to selection
                          Level 1
                          Hi PDL,

                          Thanks for the input, much appreciated.

                          I've now added the code but I'm going wrong somewhere?

                          OK - I have created a drop-down named 'City' and have specified the item values (email addresses) in the Binding category. I have now applied the JS to the field with the mouseup function but I sense I have not generated the right code based on your feedback?

                          function sendEmail() {
                          var emailAddress = xfa.resolveNode()("City").value
                          if(emailAddress == "" || emailAddress == "Off") {
                          app.alert ("You haven't selected an email address yet.");
                          } else {
                          this.var myDoc=event.target;({
                          bUI: false,
                          cTo: emailAddress,
                          cSubject: "Scotland Requirement",
                          cMsg: ""
                          });
                          }
                          }

                          In addition, I have added the
                          sendEmail()
                          to the submit button but does this work the same as Acrobat JS?
                          (I am using JS as opposed to FormCalc)

                          So in Acrobat the customisation was inside the document javascript, listbox and submit button - is this the same in LCD with JS?

                          Any more help would be appreciative,

                          All the best,

                          Jon

                          PS - My bad, it's LCD 8 and not 7 if that makes a differences to the syntax
                          • 10. Re: Submit to selection
                            Patrick Leckey Level 3
                            > xfa.resolveNode()("City").value

                            This syntax is incorrect. Have you worked with JavaScript before, or have an understanding of any form of scripting or programming before trying to migrate code designed for one product to another? This will be incredibly difficult if you don't actually understand what you're doing.

                            The correct syntax would be xfa.resolveNode("City").rawValue assuming you have named the field "City" in LiveCycle Designer.

                            > this.var myDoc=event.target;({

                            This is also incorrect, and does not even follow the example I posted above or JavaScript at all - you cannot declare a variable as a submember to a class. Also, a semi-colon ";" means "end current declaraion" and you have included one in the middle of a function call.

                            If you have no understanding of the JavaScript language you are using, you will not have much luck translating code from AcroForms to XFA since the object models are entirely different. Without understanding both of the object models and how JavaScript interacts with them, you're stuck with exactly what you have above - guessing at syntax until you happen to get it right.

                            I don't want to sound mean, but it's not something you can just guess at and make it work. You need at least a basic understanding of JavaScript before you can use it in a production form.

                            These forums aren't really about other people doing the work for you, more having experienced users help you when you don't understand something. That's not to say there may not be people out there who won't just write a solution for you free of charge. If that's what you're looking for you may want to just ask for that.
                            • 11. Re: Submit to selection
                              Level 1
                              PDL,

                              I don't understand scripting hence why I have visited this forum. I've spent hundreds of hours helping people out within the Acrobat and workflow forums for years for you to lecture me about how these forums work!

                              To belittle users is an unusual way of hanging out, if you don't want to help a user then don't bother answering
                              • 12. Re: Submit to selection
                                Patrick Leckey Level 3
                                > To belittle users is an unusual way of hanging out, if you don't want to help a user then don't bother answering

                                I'm not belittling anybody, in fact I specifically said that in my post. If that's how you took it I apologize, text doesn't convey conversational context very well. I'm simply stating that fact that you don't understand scripting yet you are trying to write your own semi-advanced scripts. I don't try to speak to my French customers in French without taking some French lessons first. Adobe/Acrobat didn't invent JavaScript - it is a pre-existing and quite complex language used all over the internet that Adobe has added APIs to in order to add functionality to Acrobat. You can't learn "Acrobat Scripting" without JavaScript, and I find a lot of people don't understand this. You need to have a base understanding of JavaScript before you can hope to understand Acrobat JavaScript.

                                function sendEmail() {
                                var emailSOM = "xfa.form.form1.#subform[0].City";
                                var emailAddress = xfa.resolveNode(emailSOM).rawValue

                                if(emailAddress == "" || emailAddress == "Off") {
                                xfa.host.messageBox("You haven't selected an email address yet.");
                                } else {
                                var myDoc = event.target;
                                myDoc.submitForm({
                                bUI: false,
                                cTo: emailAddress,
                                cSubject: "Scotland Requirement",
                                cMsg: ""
                                });
                                }
                                }

                                Without knowing the layout and hierarchy of your form, the emailSOM variable may not parse correctly (I did a 'best-guess' based on a new object added to a blank XFA form). You will have to update that to a valid XFA SOM expression based on your form layout if the default doesn't work.