Highlighted

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

Community Beginner ,
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!

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;
}
TOPICS
General troubleshooting, How to, PDF forms

Views

75

Likes

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

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

Community Beginner ,
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!

 

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;
}
TOPICS
General troubleshooting, How to, PDF forms

Views

76

Likes

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
Sep 30, 2020 0
Adobe Community Professional ,
Sep 30, 2020

Copy link to clipboard

Copied

Change the first line to:

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

 

Likes

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
Reply
Loading...
Sep 30, 2020 0
Community Beginner ,
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!

 

Likes

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
Reply
Loading...
Oct 01, 2020 0
Most Valuable Participant ,
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;
}

Likes

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
Reply
Loading...
Oct 01, 2020 0
Community Beginner ,
Oct 01, 2020

Copy link to clipboard

Copied

Perfect! That worked, thank you very much!!

Likes

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
Reply
Loading...
Oct 01, 2020 0