Link checkboxes and conditions for them

Dec 07, 2020

Copy link to clipboard

Copied

Hello to everyone.

 

I am at the beginning of the road in editing and creating editable pdf documents (I use Adobe Acrobat Pro DC) and I would need a little help in solving the problem that is detailed in the attached image.

 

I managed to introduce the checkboxes, to offer them values and also to create the total of the services that are checked. If I check several boxes in the service area, in the total area it gives me the sum of the values assigned to the checked boxes.
I failed to make the condition that gives me the ability to connect the platform area with the value area and also the condition that gives me the ability to link the service area with the value area.

 

Any help is welcome and I am grateful for it. Thank you!

All the best!

 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to

Views

104

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

Link checkboxes and conditions for them

Dec 07, 2020

Copy link to clipboard

Copied

Hello to everyone.

 

I am at the beginning of the road in editing and creating editable pdf documents (I use Adobe Acrobat Pro DC) and I would need a little help in solving the problem that is detailed in the attached image.

 

I managed to introduce the checkboxes, to offer them values and also to create the total of the services that are checked. If I check several boxes in the service area, in the total area it gives me the sum of the values assigned to the checked boxes.
I failed to make the condition that gives me the ability to connect the platform area with the value area and also the condition that gives me the ability to link the service area with the value area.

 

Any help is welcome and I am grateful for it. Thank you!

All the best!

 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to

Views

105

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
Dec 07, 2020 0
Dec 19, 2020

Copy link to clipboard

Copied

Is this a duplicated thread?

 

Was this inquiry answered already in another 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...
Dec 19, 2020 0
Jan 05, 2021

Copy link to clipboard

Copied

Thank you for your response.

 

I apologize but I don't understand the questions. Can you be a little more specific?

You can help me understand so I can answer you?

 

Thank you. All the best!

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...
Jan 05, 2021 0
Jan 05, 2021

Copy link to clipboard

Copied

I wasn't sure if your question was answered before.

 

Sometimes the users post the same question more than once in the forums which creates a duplicate of the same topic.

 

But if no one has replied to you yet, then I can help.

 

Would you mind sharing an example PDF ?

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...
Jan 05, 2021 0
Jan 06, 2021

Copy link to clipboard

Copied

Hello,

 

Now I understand your question. I posted the problem I have only once and it has not been solved yet.

I can't add the pdf file here, but I can insert a transfer link with the file.

Problem Adobe 

 

Looking forward to hearing from you. Thank you!

 

All the best!

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...
Jan 06, 2021 0
Jan 08, 2021

Copy link to clipboard

Copied

+++EDITED REPLY, fixed some typos

 

Hi, 

 

I only used checkboxes throughout the table that you provided.  I also used a field naming hierarchy for each row and columns of  checkboxes.

 

Based on my current knowledge of JavaScript the best way that I was able to make this work is described below, but there are many other ways of accomodating in this PDF a more elegant script.

 

This what I did:

 

  • For the Platform checkbox fields I named them "Platform.1",  "Platform.2",  and "Platform.3". This is the script for each one:

 

 

 

// SCRIPT FOR PLATFORM 1 CHECKBOX
var f = event.target;

if(f.value !=="Off") {

this.getField("S1.P1ValuesForPlatform").display = display.visible;
this.getField("S2.P1ValuesForPlatform").display = display.visible;
this.getField("S3.P1ValuesForPlatform").display = display.visible;
this.getField("S4.P1ValuesForPlatform").display = display.visible;
this.getField("S5.P1ValuesForPlatform").display = display.visible;

} else {


this.getField("S1.P1ValuesForPlatform").display = display.hidden; 
this.getField("S2.P1ValuesForPlatform").display = display.hidden;
this.getField("S3.P1ValuesForPlatform").display = display.hidden;
this.getField("S4.P1ValuesForPlatform").display = display.hidden;
this.getField("S5.P1ValuesForPlatform").display = display.hidden;

this.getField("S1.P1ValuesForPlatform").checkThisBox(0, false);
this.getField("S2.P1ValuesForPlatform").checkThisBox(0, false); 
this.getField("S3.P1ValuesForPlatform").checkThisBox(0, false); 
this.getField("S4.P1ValuesForPlatform").checkThisBox(0, false); 
this.getField("S5.P1ValuesForPlatform").checkThisBox(0, false); 

}



//SCRIPT FOR PLATFORM 2 CHACKBOX
var f = event.target;

if(f.value !=="Off") {

this.getField("S1.P2ValuesForPlatform").display = display.visible;
this.getField("S2.P2ValuesForPlatform").display = display.visible;
this.getField("S3.P2ValuesForPlatform").display = display.visible;
this.getField("S4.P2ValuesForPlatform").display = display.visible;
this.getField("S5.P2ValuesForPlatform").display = display.visible;

} else {

this.getField("S1.P2ValuesForPlatform").display = display.hidden; 
this.getField("S2.P2ValuesForPlatform").display = display.hidden;
this.getField("S3.P2ValuesForPlatform").display = display.hidden;
this.getField("S4.P2ValuesForPlatform").display = display.hidden;
this.getField("S5.P2ValuesForPlatform").display = display.hidden;

this.getField("S1.P2ValuesForPlatform").checkThisBox(0, false);
this.getField("S2.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S3.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S4.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S5.P2ValuesForPlatform").checkThisBox(0, false); 

}

//SCRIPT FOR PLATFORM 3 CHECKBOX

var f = event.target;

if(f.value !=="Off") {

this.getField("S1.P3ValuesForPlatform").display = display.visible;
this.getField("S2.P3ValuesForPlatform").display = display.visible;
this.getField("S3.P3ValuesForPlatform").display = display.visible;
this.getField("S4.P3ValuesForPlatform").display = display.visible;
this.getField("S5.P3ValuesForPlatform").display = display.visible;

} else {

this.getField("S1.P3ValuesForPlatform").display = display.hidden; 
this.getField("S2.P3ValuesForPlatform").display = display.hidden;
this.getField("S3.P3ValuesForPlatform").display = display.hidden;
this.getField("S4.P3ValuesForPlatform").display = display.hidden;
this.getField("S5.P3ValuesForPlatform").display = display.hidden;

this.getField("S1.P3ValuesForPlatform").checkThisBox(0, false);
this.getField("S2.P3ValuesForPlatform").checkThisBox(0, false); 
this.getField("S3.P3ValuesForPlatform").checkThisBox(0, false); 
this.getField("S4.P3ValuesForPlatform").checkThisBox(0, false); 
this.getField("S5.P3ValuesForPlatform").checkThisBox(0, false); 

}



 

 

 

 

  • For the Service Type fields,  I named five checkboxes as "ServiceType.1", "ServiceType.2" , "ServiceType.3", "ServiceType.4", "ServiceType.5". This is the script for each one:

 

 

 

// SCRIPT FOR "ServiceType.1" CHECKBOX

var f = event.target;

var platform1 = this.getField("Platform.1");
var platform2 = this.getField("Platform.2");
var platform3 = this.getField("Platform.3");

if (f.value !== "Off") {

if (platform1.value !== "Off") {this.getField("S1.P1ValuesForPlatform").checkThisBox(0, true);}
if (platform2.value !== "Off") {this.getField("S1.P2ValuesForPlatform").checkThisBox(0, true);}
if (platform3.value !== "Off") {this.getField("S1.P3ValuesForPlatform").checkThisBox(0, true);} 

} else {

this.getField("S1.P1ValuesForPlatform").checkThisBox(0, false);
this.getField("S1.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S1.P3ValuesForPlatform").checkThisBox(0, false); 

}


// SCRIPT FOR "ServiceType.2" CHECKBOX

var f = event.target;

var platform1 = this.getField("Platform.1");
var platform2 = this.getField("Platform.2");
var platform3 = this.getField("Platform.3");

if (f.value !== "Off") {

if (platform1.value !== "Off") {this.getField("S2.P1ValuesForPlatform").checkThisBox(0, true);}
if (platform2.value !== "Off") {this.getField("S2.P2ValuesForPlatform").checkThisBox(0, true);}
if (platform3.value !== "Off") {this.getField("S2.P3ValuesForPlatform").checkThisBox(0, true);} 

} else {

this.getField("S2.P1ValuesForPlatform").checkThisBox(0, false);
this.getField("S2.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S2.P3ValuesForPlatform").checkThisBox(0, false); 

}


// SCRIPT FOR "ServiceType.3" CHECKBOX

var f = event.target;

var platform1 = this.getField("Platform.1");
var platform2 = this.getField("Platform.2");
var platform3 = this.getField("Platform.3");

if (f.value !== "Off") {

if (platform1.value !== "Off") {this.getField("S3.P1ValuesForPlatform").checkThisBox(0, true);}
if (platform2.value !== "Off") {this.getField("S3.P2ValuesForPlatform").checkThisBox(0, true);}
if (platform3.value !== "Off") {this.getField("S3.P3ValuesForPlatform").checkThisBox(0, true);} 

} else {

this.getField("S3.P1ValuesForPlatform").checkThisBox(0, false);
this.getField("S3.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S3.P3ValuesForPlatform").checkThisBox(0, false); 

}


// SCRIPT FOR "ServiceType.4" CHECKBOX

var f = event.target;

var platform1 = this.getField("Platform.1");
var platform2 = this.getField("Platform.2");
var platform3 = this.getField("Platform.3");

if (f.value !== "Off") {

if (platform1.value !== "Off") {this.getField("S4.P1ValuesForPlatform").checkThisBox(0, true);}
if (platform2.value !== "Off") {this.getField("S4.P2ValuesForPlatform").checkThisBox(0, true);}
if (platform3.value !== "Off") {this.getField("S4.P3ValuesForPlatform").checkThisBox(0, true);} 

} else {

this.getField("S4.P1ValuesForPlatform").checkThisBox(0, false);
this.getField("S4.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S4.P3ValuesForPlatform").checkThisBox(0, false); 

}


// SCRIPT FOR "ServiceType.5" CHECKBOX

var f = event.target;

var platform1 = this.getField("Platform.1");
var platform2 = this.getField("Platform.2");
var platform3 = this.getField("Platform.3");

if (f.value !== "Off") {

if (platform1.value !== "Off") {this.getField("S5.P1ValuesForPlatform").checkThisBox(0, true);}
if (platform2.value !== "Off") {this.getField("S5.P2ValuesForPlatform").checkThisBox(0, true);}
if (platform3.value !== "Off") {this.getField("S5.P3ValuesForPlatform").checkThisBox(0, true);} 

} else {

this.getField("S5.P1ValuesForPlatform").checkThisBox(0, false);
this.getField("S5.P2ValuesForPlatform").checkThisBox(0, false); 
this.getField("S5.P3ValuesForPlatform").checkThisBox(0, false); 

}


 

 

 

 

NOTE: Up to this point all of the checkboxes were created in rows. But based on your requirements, note in the script above how I named all of the service type checkboxes in a column fashion to make the calculation work as intended .

 

All the service type checkboxes were named usin a prefix naming convention so that the intended calculations perform correctly  if the user decides to do manual changes.

 

Here's the breakdown for the Value Type checkboxes (I added an export value of "1" in all of them):

 

1st Column: 

  • S1.P1ValuesForPlatform
  • S1.P2ValuesForPlatform
  • S1.P3ValuesForPlatform

 

2nd Column: 

  • S2.P1ValuesForPlatform
  • S2.P2ValuesForPlatform
  • S2.P3ValuesForPlatform

 

3rd Column: 

  • S3.P1ValuesForPlatform
  • S3.P2ValuesForPlatform
  • S3.P3ValuesForPlatform

 

4th Column: 

  • S4.P1ValuesForPlatform
  • S4.P2ValuesForPlatform
  • S4.P3ValuesForPlatform

 

5th Column: 

  • S5.P1ValuesForPlatform
  • S5.P2ValuesForPlatform
  • S5.P3ValuesForPlatform

 

And last, in the Total Value field I used the following custom calculation script:

 

 

var a = this.getField("S1").getArray();
var b = this.getField("S2").getArray();
var c = this.getField("S3").getArray();
var d = this.getField("S4").getArray();
var e = this.getField("S5").getArray();

x = 0;

if (this.getField("ServiceType.1").value !=="Off") {for (i =0; i < a.length; i++)  if (a[i].valueAsString !== "Off")  x +=1;}

if (this.getField("ServiceType.2").value !=="Off") {for (i =0; i < b.length; i++)  if (b[i].valueAsString !== "Off")  x +=1;}

if (this.getField("ServiceType.3").value !=="Off") {for (i =0; i < c.length; i++)  if (c[i].valueAsString !== "Off")  x +=1;}

if (this.getField("ServiceType.4").value !=="Off") {for (i =0; i < d.length; i++)  if (d[i].valueAsString !== "Off")  x +=1;}

if (this.getField("ServiceType.5").value !=="Off") {for (i =0; i < e.length; i++)  if (e[i].valueAsString !== "Off")  x +=1;}

event.value = "Total Value: " + x;

 

 

 

 

Here's a copy of the PDF so you can explore these scripts and improve them:

 

https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:86f7a020-4c93-4573-ac5d-8e6b1778c263

 

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...
Jan 08, 2021 0
Jan 08, 2021

Copy link to clipboard

Copied

I forgot to add a screenshot of the resulting PDF:

 

asobeproblem.png

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...
Jan 08, 2021 0
Jan 13, 2021

Copy link to clipboard

Copied

Thank you a lot! I will try to implement all the information in the coming days.

 

Have a nice day!

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...
Jan 13, 2021 1
Jan 13, 2021

Copy link to clipboard

Copied

A tip: although you are making editable files, because you are using the forms features, we call it "fillable" not "editable" even if it isn't an actual form. Hope this is useful info. 

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...
Jan 13, 2021 1