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

displaying strings based on checkbox input (javascript)

New Here ,
Sep 08, 2020 Sep 08, 2020

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
1.5K
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
LEGEND ,
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 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.

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
LEGEND ,
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 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.

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

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

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