Skip to main content
Known Participant
February 8, 2016
解決済み

One field to retreive email address from several other fields

  • February 8, 2016
  • 返信数 1.
  • 422 ビュー

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);

このトピックへの返信は締め切られました。
解決に役立った回答 try67

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;

     }

}

返信数 1

try67
Community Expert
try67Community Expert解決!
Community Expert
February 8, 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;

     }

}