Skip to main content
Known Participant
May 24, 2023
Answered

Adobe Forms If/else statement

  • May 24, 2023
  • 1 reply
  • 679 views

I am a complete novice using Javascript so I would like some help please.

I have a form and would like a field (Day4) to autopopulate with a number from another field or three depending on which field has an entry. For example: if "Day1" has a number in it (i.e. 100) "Day4" should have that same number, however, if "Day1" is blank then "Day4" should be populated with "Day2"'s number, and so on and if all fields are blank then "Day4" is also blank.

 

I have written the following, but I am getting an error "The value entered does not match the format of the field [Day4]"

 

var D1 = this.getField("Day1").value;
var D2 = this.getField("Day2").value;
var D3 = this.getField("Day3").value;

if (D2 == "" && D3 == ""){
event.value = "D1";
}
else if (D1 == "" && D3 == ""){
event.value = "D2";
}
else if (D1 == "" && D2 == ""){
event.value = "D3";
}
else event.value = ""

 

Any assistance would be greatly appreciated.

This topic has been closed for replies.
Correct answer Bernd Alheit

Use

 event.value = D1;

and so on.

 

1 reply

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
May 24, 2023

Use

 event.value = D1;

and so on.

 

Known Participant
May 24, 2023

Brilliant thank you it was doing my head in 🙂