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

Making a drop down box field read only based on the value selected in another drop down box

Community Beginner ,
Sep 30, 2020 Sep 30, 2020

Copy link to clipboard

Copied

Hello,

I have two drop down boxe fields on my form.  One is called Rejection1 and the other is called Disposition1 (both fields are NOT read-only by default).  If the user filling out the form selects "Material Defect" in the Rejection1 field, i want the Disposition1 field to become read-only so it can't be filled out.  If the user selects anything else in the Rejection1 field then the Disposition1 field should NOT be read-only.

 

Here's the validation field i have entered in the Rejection1 field but am obviously missing something as no matter what i select in the Rejection1 field, the Disposition1 field is made as read-only.  Can someone help me with this?

 

if (event.value = "Material Defect") (this.getField("Disposition1").readonly = true);
else (this.getField("Disposition1").readonly = false);

 

i've also tried:

if (event.value = 'Material Defect') (this.getField("Disposition1").readonly = true);
else (this.getField("Disposition1").readonly = false);

 

Thank you!

 

TOPICS
General troubleshooting , How to , PDF forms

Views

544

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

correct answers 2 Correct answers

Community Expert , Sep 30, 2020 Sep 30, 2020

Change the first line to:

if (event.value == "Material Defect")

 

Votes

Translate

Translate
Community Expert , Oct 01, 2020 Oct 01, 2020

Try this code:

 

if (event.value == "Material Defect") {
	this.getField("Disposition1").readonly = true;
	this.getField("Disposition1").value = "QC Check";
} else {
	this.getField("Disposition1").readonly = false;
}

Votes

Translate

Translate
Community Expert ,
Sep 30, 2020 Sep 30, 2020

Copy link to clipboard

Copied

Change the first line to:

if (event.value == "Material Defect")

 

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 Beginner ,
Oct 01, 2020 Oct 01, 2020

Copy link to clipboard

Copied

Thank you! That worked! - One other related question.  Is there a way i can add to that script so that if "Material Defect" is chosen in the Rejection1 field then "QC Check" is automatically chosen in the Disposition1 field AND the Disposition1 field is marked as read only as we now have it working from the script?

 

Here's what my current validation script for the Rejection1 field looks like since applying your fix:

 

if (event.value == "Material Defect") (this.getField("Disposition1").readonly = true);
else (this.getField("Disposition1").readonly = false);

 

Thanks!

 

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 01, 2020 Oct 01, 2020

Copy link to clipboard

Copied

Try this code:

 

if (event.value == "Material Defect") {
	this.getField("Disposition1").readonly = true;
	this.getField("Disposition1").value = "QC Check";
} else {
	this.getField("Disposition1").readonly = false;
}

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 Beginner ,
Oct 01, 2020 Oct 01, 2020

Copy link to clipboard

Copied

LATEST

Perfect! That worked, thank you very much!!

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