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

JavaScript Checkbox

New Here ,
Feb 17, 2022 Feb 17, 2022

I have a text feild "ONLY IF NO" i want to populate with text from another field "NWA FULL NAME" only if a specific checkbox is checked. I have tried many different methods and believe i am close. The blow script gives me a syntax error missing ) after argument list 1: at line 2. No matter where i place the ) same result. Any advice on how to fix this or possibly a different method? 

 

I am placing the below script into the checkbox:

 

var INPUT = this.getField(“ONLY IF NO).value;

var APPL = this.getField(“NWA FULL NAME).value;

 

this.getField(“ONLY IF NO”).value = APPL;

TOPICS
How to , JavaScript , PDF forms
530
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 ,
Feb 17, 2022 Feb 17, 2022

Use "ONLY IF NO" in the first line and  "NWA FULL NAME" in the second line. 

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 ,
Feb 17, 2022 Feb 17, 2022

Maybe I am over thinking this but that is what I did. 

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 ,
Feb 17, 2022 Feb 17, 2022

In your script you use  "ONLY IF NO and  "NWA FULL NAME

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 ,
Feb 17, 2022 Feb 17, 2022

You have a couple of different errors. First, strings must be completely inclosed in quotes. The first two lines are missing the closing quotes. But, the quote characters are wrong. You must use only ASCII characters for JavaScript code.  It looks like this code was edited or copied from a word processor. 

 

You did not say in which event the script is placed. Please proivide this information.

After you fix the syntax errors I'll tell you how to change the code so it works.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Feb 17, 2022 Feb 17, 2022

Apologies I am not well versed in using any form of Script and yes I did copy that from a word processor. Thank you for pointing me to the reference. As far as events I believe it will be a MouseUp event. Again, I am new to thins and have had no formal training. Apprecitate the assist. Screen Shot 2022-02-17 at 12.05.57.pngexpand image

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 ,
Feb 17, 2022 Feb 17, 2022

Where does you set APPL? 

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 ,
Feb 17, 2022 Feb 17, 2022
LATEST

Ah I see the error. Thank you. 

Screen Shot 2022-02-17 at 12.36.08.pngexpand image

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 ,
Feb 17, 2022 Feb 17, 2022

As 'Mouse UP' event of checkbox use this script:

 

var INPUT = this.getField("ONLY IF NO");
var APPL = this.getField("NWA FULL NAME").value;

INPUT.value = event.target.value == "Off" ? "" : APPL;

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