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

Fields inactive until checkbox is checked

New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Looking for a way to keep a set of fields inactive (not fillable, read-only etc) until a single checkbox is checked. I have pretty much an entire page that does not need filled in unless someone would check a box for that option.

Thanks

TOPICS
PDF forms

Views

778

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 , Oct 20, 2017 Oct 20, 2017

Use this code as the Mouse Up event of the check-box:

var fields = ["Field1", "Field2", "Field3"];

for (var i in fields) {

    var f = this.getField(fields);

    if (event.target.value=="Off") {

        f.readonly = true;

        f.value = f.defaultValue;

    } else {

        f.readonly = false;

    }

}

  

Adjust the names of the fields in the first line to match those in your file, of course.

Votes

Translate

Translate
Community Expert ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Use this code as the Mouse Up event of the check-box:

var fields = ["Field1", "Field2", "Field3"];

for (var i in fields) {

    var f = this.getField(fields);

    if (event.target.value=="Off") {

        f.readonly = true;

        f.value = f.defaultValue;

    } else {

        f.readonly = false;

    }

}

  

Adjust the names of the fields in the first line to match those in your file, of course.

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Can't get that script to work. Any suggestions?

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
Engaged ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

LATEST

I've managed to understand the rest of the code except for one line.

 

What is 
for (var i in fields)

 

What does the 'i' refer to?

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Actually I just noticed it does work, but it's doing the opposite. Its only making them inactive when the box is UNchecked.

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 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Are you sure you placed it where I indicated?

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Yes, at least I think so...

Screen Shot 2017-10-20 at 1.20.08 PM.png

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Does the export value of the checkbox affect the script? Mine is set to YES

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 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Sorry, I misunderstood how you wanted it to work.

Simply change line #4 from:

if (event.target.value=="Off") {

to:

if (event.target.value!="Off") {

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

try67...

This script was working till I added some additional field names to it. I'm getting the below error. Can you tell me what I need to do? I appreciate your help!

Screen Shot 2017-10-20 at 3.31.20 PM.png

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 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

You probably missed a comma or something like that. Post the code as text, not as an image.

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
New Here ,
Oct 20, 2017 Oct 20, 2017

Copy link to clipboard

Copied

Sorry. Think I found it. Missed a " mark.

Again, thank you for your assistance. Very helpful

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