3 Replies Latest reply on Jan 16, 2012 3:57 PM by jasonconlaw

    Combining several data fields into a single textbox

    jasonconlaw

      Hi,

      Please help!


      I have 3 user-entered textboxes at the  beginning of the form: FirstName, MiddleName, LastName.

      At the end, I have a textbox which I want to merge those 3 textboxes into a single textbox, which displays: LastName (comma) MiddleName (space) LastName.

       

      Any help is appreciated. Thanks.

        • 1. Re: Combining several data fields into a single textbox
          Varma_LC Level 3

          in the calculate event of the final text field use the following JavaScript code....however you may have to update based on your Hierarchy....

           

          var lname = "";
          var mname = "";
          var fname = "";


          if (!LastName.isNull && (!MiddleName.isNull || !FirstName.isNull)) {
               lname = LastName.rawValue + ", ";
          }else if(!LastName.isNull) {
          lname = LastName.rawValue;
          }

          if (!MiddleName.isNull && !FirstName.isNull) {
               mname = MiddleName.rawValue + " ";
          }else if (!MiddleName.isNull){
          mname = MiddleName.rawValue;
          }

          if (!FirstName.isNull) {
          fname = FirstName.rawValue;
          }

          this.rawValue = lname + mname + fname;

          • 2. Re: Combining several data fields into a single textbox
            jasonconlaw Level 1

            Thank you so much for your help.

            However, it doesn't seem to be working. I am a newbie at this, maybe I am doing something wrong.

            I entered the Javascript into the textbox (for the combined field on page 2 of the form), but nothing happened.

            Do I have to set the Type Value and Data Binding? I tried every combination, but it doesn't work. Can you show me more specifically?

            Thank you so much!

            • 3. Re: Combining several data fields into a single textbox
              jasonconlaw Level 1

              This is what appears in the combined textbox after execution:

              [object XFAObject][object XFAObject]

               

               

              Please help. Thanks.