2 Replies Latest reply on Dec 8, 2013 9:13 AM by gkaiseril

    two different text Fields information in to another one text Field

    omanbux Level 1

      hi, i want to add two different text Fields information in to another one text Field. i mean if i enter one text Field to "john" & other text Field"smith" them 3rd text Field should auto update as a " john smith". ( one space need between two words). so pls help me to do this. thanks..

        • 1. Re: two different text Fields information in to another one text Field
          omanbux Level 1

          i have found answer after posting this. so now problem is solved.

          // Custom Calculate script

          event.value = getField("f1").valueAsString + "    " + getField("f2").valueAsString;

          • 2. Re: two different text Fields information in to another one text Field
            gkaiseril MVP & Adobe Community Professional

            Unfortunatel unlees both fields have data a leding or trailing blank will be add to the field and if there is no data in either of the fields a blank will be inserted into the field. There are better solutions. You could check for blank fields and then adjust the result as needed.

             

            // Custom Calculate script
            var field1 = getField("f1").valueAsString;
            var field2 = getField("f2").valueAsString;
            switch(true) {
            defualt:
            event.value = "";
            break;
            case(field1!= "" && field2 == ""):
            event.value = field1;
            break;
            case(field1 == null && field2 != ""):
            event.value = field2;
            break;
            case(field1 != "" && field2 != ""):
            event.value = field1 + " " + field2;
            break;
            }

             

            There is even a more generalized function similar to the above that can handle up to 3 strings and an optional seperator and return the properly formatted string adjusting for null data.