Skip to main content
Participating Frequently
November 29, 2018
Answered

Javacript to enter check box value into text box.

  • November 29, 2018
  • 1 reply
  • 1108 views

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?

This topic has been closed for replies.
Correct answer Thom Parker

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.

1 reply

Thom Parker
Community Expert
Community Expert
November 30, 2018

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 PDFScriptingUse the Acrobat JavaScript Reference early and often
kileyCFCAuthor
Participating Frequently
November 30, 2018

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?

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
November 30, 2018

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 PDFScriptingUse the Acrobat JavaScript Reference early and often