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

Prefill one field depending on 2 different drop downs

Contributor ,
Oct 08, 2024 Oct 08, 2024

I'm trying to do a 'if this dropdown is xyz AND this other drop down is abc, then text needs to be .....

The variables are both drop downs. The below works ok until the bits in blue are added. Apologies if the below isn't pretty, but please could someone correct where I've gone wrong.

 

var OffCode = this.getField("O.aff_es_:prefill").value;
var InstChoice = this.getField("Installation choice_es_:prefill").value
if (OffCode=="...") event.value = " ";
else if (OffCode=="FSPE") event.value = "Je ne souhaite ........";
else if (OffCode=="FSFI") event.value = "Je ne souhaite ........";
else if (OffCode=="FSPB") event.value = "Je ne souhaite .........";
else if (OffCode=="FSPB") event.value &&(InstChoice=="Pas d’équipement(s) à installer") event.value = "Je ne souhaite ........";
else event.value = " ";

TOPICS
How to , JavaScript , PDF , PDF forms
635
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
1 ACCEPTED SOLUTION
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Your syntax is off. The entire IF condition has to be in parentheses and the && operator has to be located between the two conditions. Try this:

 

else if (OffCode=="FSPB" && InstChoice=="Pas d’équipement(s) à installer") event.value = "Je ne souhaite ........";

 

However, you also have a logical error, because if OffCode=="FSPB" then the previous condition before that line will be true, and you will never reach it. To solve it you can use nesting, like this:

 

else if (OffCode=="FSPB") {
	if (InstChoice=="Pas d’équipement(s) à installer") event.value = "Je ne souhaite ........";
	else event.value = "Je ne souhaite .........";
}

View solution in original post

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
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Your syntax is off. The entire IF condition has to be in parentheses and the && operator has to be located between the two conditions. Try this:

 

else if (OffCode=="FSPB" && InstChoice=="Pas d’équipement(s) à installer") event.value = "Je ne souhaite ........";

 

However, you also have a logical error, because if OffCode=="FSPB" then the previous condition before that line will be true, and you will never reach it. To solve it you can use nesting, like this:

 

else if (OffCode=="FSPB") {
	if (InstChoice=="Pas d’équipement(s) à installer") event.value = "Je ne souhaite ........";
	else event.value = "Je ne souhaite .........";
}
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
Contributor ,
Oct 08, 2024 Oct 08, 2024
LATEST

Thank you as always @try67 - much appreciated

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