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

displaying strings based on checkbox input (javascript)

New Here ,
Sep 08, 2020 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

863

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


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 outp

...

Votes

Translate

Translate
Community Expert ,
Sep 08, 2020 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.

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

Copy link to clipboard

Copied

LATEST

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

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