Javacript to enter check box value into text box.

Community Beginner ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

I have five checkmark boxes (1,2,3,4,5) and when any of the boxes are checked, I need that value of the checkbox to be added to a text box. Is there a script that can do this and separate the values with a comma?

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

358

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Nov 30, 2018 Nov 30, 2018
No, I missed one critical bit in that script. Add this to the endevent.value = cValue;And you'll need to change the export value to the text you want added in the text box.

Likes

Translate

Translate
Adobe Community Professional ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Yes, Use a calculation script on the text box.  Like this:

var cValue = "";

if(this.getField("Check1").value != "Off")

  cValue += this.getField("Check1").value + ",";

if(this.getField("Check2").value != "Off")

  cValue += this.getField("Check2").value + ",";

etc.

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

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
community guidelines
Community Beginner ,
Nov 30, 2018 Nov 30, 2018

Copy link to clipboard

Copied

I tried this in the 'custom calculation script' with the checkboxes named 'Check1', 'Check2', but it didn't enter the values into the text box.

The export value for the checkboxes is 'Yes'. Would this have anything to do with it not working?

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
community guidelines
Adobe Community Professional ,
Nov 30, 2018 Nov 30, 2018

Copy link to clipboard

Copied

No, I missed one critical bit in that script. Add this to the end

event.value = cValue;

And you'll need to change the export value to the text you want added in the text box.

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

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
community guidelines
Community Beginner ,
Nov 30, 2018 Nov 30, 2018

Copy link to clipboard

Copied

LATEST

AWESOME! It worked! Thanks for your help!

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
community guidelines