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

Prefill one field depending on 2 different drop downs

Contributor ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

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

Views

192

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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 .........";
}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Thank you as always @try67 - much appreciated

Votes

Translate

Translate

Report

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