How to make check box to disable several text boxes and otherwise

Community Beginner ,
Aug 30, 2022 Aug 30, 2022

Copy link to clipboard

Copied

Hi everyone. In my form I need all the text boxes ("choice 6' "choice 7" "choice 8" and "choice 9") to be deactivated if the check box ("no excursion") is on. So all the text boxes become empty and readonly. And if you uncheck the check box, they should become available again. 

 

And othervise, if you type anything in any of the text boxes, the check box becomes unavailable. 

TOPICS
PDF forms

Views

40

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
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 30, 2022 Aug 30, 2022

In one of text fields as 'Custom calculation script' use this:

var c7 = this.getField("Choice 7");
var c8 = this.getField("Choice 8");
var c9 = this.getField("Choice 9");
var c10 = this.getField("Choice 10");
var chk = this.getField("No excursion 2");
c7.readonly = chk.valueAsString == "Off" ? false : true;
c8.readonly = chk.valueAsString == "Off" ? false : true;
c9.readonly = chk.valueAsString == "Off" ? false : true;
c10.readonly = chk.valueAsString == "Off" ? false : true;
chk.readonly = (c7.value||c8

...

Likes

Translate

Translate
Community Expert ,
Aug 30, 2022 Aug 30, 2022

Copy link to clipboard

Copied

1. You wrote that your fields are named "no excursion", Choice 6,7,8,9 in your photo fields are named "No excursion 2" and choices 7,8,9,10?

2. I don't get your explanation, if checkbox is checked text fields become read only and empty but if any field have text checkbox is unavailable? That doesn't make sense, why setting script in checkbox to empty fields if they have value checkbox can't be checked?

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
community guidelines
Community Beginner ,
Aug 30, 2022 Aug 30, 2022

Copy link to clipboard

Copied

Sorry for confusing) I sent the screenshot from the copy of the file. Will try to explain what I mean) there should be only two options for people filling the form: either they are filling the text boxes (choice 7,8,9,10), or they switch on the check box (No excursion 2). So if any of the text boxes are filled, the check box becomes unavailable and otherwise. Hope I didn't make it very confusing. 

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
community guidelines
Community Expert ,
Aug 30, 2022 Aug 30, 2022

Copy link to clipboard

Copied

In one of text fields as 'Custom calculation script' use this:

var c7 = this.getField("Choice 7");
var c8 = this.getField("Choice 8");
var c9 = this.getField("Choice 9");
var c10 = this.getField("Choice 10");
var chk = this.getField("No excursion 2");
c7.readonly = chk.valueAsString == "Off" ? false : true;
c8.readonly = chk.valueAsString == "Off" ? false : true;
c9.readonly = chk.valueAsString == "Off" ? false : true;
c10.readonly = chk.valueAsString == "Off" ? false : true;
chk.readonly = (c7.value||c8.value||c9.value||c10.value) ? true : 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
community guidelines
Community Beginner ,
Aug 30, 2022 Aug 30, 2022

Copy link to clipboard

Copied

LATEST

OMG! It works! 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
community guidelines

Make content for your business needs with Adobe Express.

Get started easily with free templates: