Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

One field to retreive email address from several other fields

New Here ,
Feb 07, 2016 Feb 07, 2016

I have a form where it asks the user in several different locations for their email address. 6 to be exact. The goal of this form is to get their email address with a series of different questions, and subsequent answers. However, the email address is to ultimately end up in one field. So if the user inputs their email address in any field 1-6, it ends up in field 7. The user can possibly enter their email address in more than one field, but the first instace of an email address input entered, ends up in field 7. I have tried a multitude of different code snipets, but nothing seems to work. This was the last code I tried using, putting it in each text field in a Mouse up trigger.

        //set the vars

        var one = this.getField("501");

        var two = this.getField("502");

        var three = this.getField("503");

        var four = this.getField("504");

        var five = this.getField("505");

        var six = this.getField("506");

        var seven = this.getField("507");

        //this function that checks if the destination field is blank and if so popluates it.

        function checkAndPopulate(orig,populate){

        if(populate.value==''||populate.value==null){populate.value=orig.value}

        }

        //copy value of one to two, three and four

        checkAndPopulate(one,two);

        checkAndPopulate(one,three);

        checkAndPopulate(one,four);

        checkAndPopulate(one,five);

        checkAndPopulate(one,six);

        checkAndPopulate(one,seven);

TOPICS
Acrobat SDK and JavaScript , Windows
402
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 08, 2016 Feb 08, 2016

Remove all of these scripts you added and instead add this one as the custom calculation script of the target field:

var fields = ["501", "502", "503", "504", "505", "506", "507"];

event.value = "";

for (var i in fields) {

    if (this.getField(fields).valueAsString!="") {

         event.value = this.getField(fields).valueAsString;

         break;

     }

}

Translate
Community Expert ,
Feb 08, 2016 Feb 08, 2016
LATEST

Remove all of these scripts you added and instead add this one as the custom calculation script of the target field:

var fields = ["501", "502", "503", "504", "505", "506", "507"];

event.value = "";

for (var i in fields) {

    if (this.getField(fields).valueAsString!="") {

         event.value = this.getField(fields).valueAsString;

         break;

     }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines