Checkbox checked, other checkboxes become both checked & disabled

Explorer ,
Feb 07, 2018

Copy link to clipboard

Copied

Hi,

I have three checkboxes in my form named checkbox1, checkbox2 and checkbox3.

I wish the following to happen:

If checkbox1 is checked, then:

• checkbox2 and checkbox3 also becomes checked

• but at the same time checkbox 2 and checkbox3 also become disabled (by disabled

I mean not checkable, not clickable).

I have this script that does half the job, it disables checkbox 2 and checkbox3 when checkbox1 is checked:

// set readonly property based on the value of this field compared to "Off";

this.getField("checkbox2").readonly = (event.target.value != "Off");

this.getField("checkbox3").readonly = (event.target.value != "Off");

Though, as described above, I want checkbox2 and checkbox3 to become both checked and disabled at the same time.

How would this script look like?

Thanks for your help!

Greatings,

Dennis (Javascript beginner)

TOPICS
Acrobat SDK and JavaScript, Windows

Views

173

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

Checkbox checked, other checkboxes become both checked & disabled

Explorer ,
Feb 07, 2018

Copy link to clipboard

Copied

Hi,

I have three checkboxes in my form named checkbox1, checkbox2 and checkbox3.

I wish the following to happen:

If checkbox1 is checked, then:

• checkbox2 and checkbox3 also becomes checked

• but at the same time checkbox 2 and checkbox3 also become disabled (by disabled

I mean not checkable, not clickable).

I have this script that does half the job, it disables checkbox 2 and checkbox3 when checkbox1 is checked:

// set readonly property based on the value of this field compared to "Off";

this.getField("checkbox2").readonly = (event.target.value != "Off");

this.getField("checkbox3").readonly = (event.target.value != "Off");

Though, as described above, I want checkbox2 and checkbox3 to become both checked and disabled at the same time.

How would this script look like?

Thanks for your help!

Greatings,

Dennis (Javascript beginner)

TOPICS
Acrobat SDK and JavaScript, Windows

Views

174

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
Feb 07, 2018 0
Most Valuable Participant ,
Feb 07, 2018

Copy link to clipboard

Copied

When checkbox1 is unchecked, should they also be automatically unchecked?

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...
Feb 07, 2018 0
Explorer ,
Feb 07, 2018

Copy link to clipboard

Copied

Yes that is correct.

When checkbox1 is unchecked, they should automatically become unchecked.

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...
Feb 07, 2018 0
Most Valuable Participant ,
Feb 07, 2018

Copy link to clipboard

Copied

Then use this code:

this.getField("checkbox2").tickThisBox(0, (event.target.value != "Off"));

this.getField("checkbox3").tickThisBox(0, (event.target.value != "Off"));

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...
Feb 07, 2018 0
Adobe Community Professional ,
Feb 07, 2018

Copy link to clipboard

Copied

You already have the code for this. On the other thread.

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...
Feb 07, 2018 0
Explorer ,
Feb 08, 2018

Copy link to clipboard

Copied

Thanks try67 for helping me out.

Thom just helped me realize what I was doing wrong on the other thread.

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...
Feb 08, 2018 0