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

Javascript to show/hide multiple checkboxes with radio buttons

New Here ,
Jul 23, 2024 Jul 23, 2024

I'm preparing a fillable form on Acrobat Pro.

I have a radio button group with 3 options.  Each radio button option will show or hide 30-35 check boxes.  Is there a javascript I can add that will do this? 

For a very short example:

Radio Button Choice: "C&I" will HIDE:  "Check Box Cons 1-1", "Check Box Cons 1-2", "Check Box Cons 1-3" , "Check Box Cons 2-1" and SHOW "Check Box Bus 5-1", "Check Box Bus 5-2", "Check Box Bus 5-3"

 

Thanks for any sugguestions!

TOPICS
How to , JavaScript , PDF forms
1.1K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Place this script as a Mouse up Action in the concerned radiobutton:

 

if (event.target.value) != "Off") {
	
	for (var i=1; i<4; i++) {
		this.getField("Check Box Cons 1-" + i).display = display.hidden;
		this.getField("Check Box Bus 5-" + i).display = display.visible;
	}
	this.getField("Check Box Cons 2-1").display = display.hidden;
}

else {
	for (var i=1; i<4; i++) {
		this.getField("Check Box Cons 1-" + i).display = display.visible;
		this.getField("Check Box Bus 5-" + i).display = display.hidden;
	}
	this.getField("Check Box Cons 2-1").display = display.visible;
}

Acrobate du PDF, InDesigner et Photoshopographe

View solution in original post

Translate
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 ,
Jul 23, 2024 Jul 23, 2024

Place this script as a Mouse up Action in the concerned radiobutton:

 

if (event.target.value) != "Off") {
	
	for (var i=1; i<4; i++) {
		this.getField("Check Box Cons 1-" + i).display = display.hidden;
		this.getField("Check Box Bus 5-" + i).display = display.visible;
	}
	this.getField("Check Box Cons 2-1").display = display.hidden;
}

else {
	for (var i=1; i<4; i++) {
		this.getField("Check Box Cons 1-" + i).display = display.visible;
		this.getField("Check Box Bus 5-" + i).display = display.hidden;
	}
	this.getField("Check Box Cons 2-1").display = display.visible;
}

Acrobate du PDF, InDesigner et Photoshopographe
Translate
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 ,
Jul 23, 2024 Jul 23, 2024

Use the mouse up action of all three radio buttons:

if(event.target.value=="C&I")

{

this.getField("Check Box Cons 1-1").display=display.hidden;

this.getField("Check Box Cons 1-2").display=display.hidden;

this.getField("Check Box Cons 1-3").display=display.hidden;

this.getField("Check Box Cons 2-1").display=display.hidden;

 

this.getField("Check Box Bus 5-1").display=display.visible;

this.getField("Check Box Bus 5-2").display=display.visible;

this.getField("Check Box Bus 5-3").display=display.visible;

}

else

{

this.getField("Check Box Cons 1-1").display=display.visible;

this.getField("Check Box Cons 1-2").display=display.visible;

this.getField("Check Box Cons 1-3").display=display.visible;

this.getField("Check Box Cons 2-1").display=display.visible;

 

this.getField("Check Box Bus 5-1").display=display.hidden;

this.getField("Check Box Bus 5-2").display=display.hidden;

this.getField("Check Box Bus 5-3").display=display.hidden;

}

 

Translate
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 ,
Jul 23, 2024 Jul 23, 2024
LATEST

YES! Perfect! Thank you so much!

Translate
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