Highlighted

displaying strings based on checkbox input (javascript)

New Here ,
Sep 08, 2020

Copy link to clipboard

Copied

I'm trying to get the text from an input form, to show in a second PDF, but only the ones selected in the input form. 

the user will export the data from the input form to a fdf file, and then import it in the second PFD file.

 

I'm using form fields, and in theory I know what it should do, I just need help putting it in javascript. 

here's the idea: 

 

var: finaltext;

if checkbox1=true -> add textfield1 to finaltext

if checkbox2=true -> add textfiels1 to finaltext

etc...

 

or something like: 

var: i;

for each checkbox[1]{

if checkbox=true(

add textfield to finaltext;

i++)

 

It's just a little too advanced for me 🙂 could someone help me out? 
I added a graph of what the final result should be. 

 

Thanks 

 

 

TOPICS
Create PDFs, How to, PDF forms

Views

30

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

displaying strings based on checkbox input (javascript)

New Here ,
Sep 08, 2020

Copy link to clipboard

Copied

I'm trying to get the text from an input form, to show in a second PDF, but only the ones selected in the input form. 

the user will export the data from the input form to a fdf file, and then import it in the second PFD file.

 

I'm using form fields, and in theory I know what it should do, I just need help putting it in javascript. 

here's the idea: 

 

var: finaltext;

if checkbox1=true -> add textfield1 to finaltext

if checkbox2=true -> add textfiels1 to finaltext

etc...

 

or something like: 

var: i;

for each checkbox[1]{

if checkbox=true(

add textfield to finaltext;

i++)

 

It's just a little too advanced for me 🙂 could someone help me out? 
I added a graph of what the final result should be. 

 

Thanks 

 

 

TOPICS
Create PDFs, How to, PDF forms

Views

31

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
Sep 08, 2020 0
Adobe Community Professional ,
Sep 08, 2020

Copy link to clipboard

Copied


You can use something like the script shown below as a custome calulation script of the text field(s) where you want the text to show when a checkbox is checked:

if ((this.getField("Check Box 3").isBoxChecked(0)== true)) {
event.value = "third text: qui doluptatiam vel et pa aspitatem sollate moluptaquo coribus et, si";
} else {
event.value ="";

 

NOTE: For the type of workflow that you're trying to accomplish here I wouldn't recommend to use an getArray() method in order to grab all of the output values from each selection into a single multi-line textfield.

 

You can dedicate a single text field to display the output  text per  checkbox. Since the output value are long text phrases you may run into paragraph and text formatting limitations. 

 

Also, you can't expect nor treat  the static content of a PDF to interact with JavaScript; you'll need to use text field objects, dropdown menus, etc.

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...
Sep 08, 2020 1
try67 LATEST
Most Valuable Participant ,
Sep 08, 2020

Copy link to clipboard

Copied

You're missing a closing curly bracket at the end of the code...

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...
Sep 08, 2020 0