Copy link to clipboard
Copied
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);
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;
}
}
Copy link to clipboard
Copied
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;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now