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

Javascript Question - interactive PDF form - check box, text field.

Community Beginner ,
Nov 11, 2016 Nov 11, 2016

HI Forum experts ,

I have created an interactive PDF form with check-boxes and text fields.  I wanted to know if it is possible for 'checkbox 1' to tick, when 'text field 1' has had text entered (JavaScript on the textbox?).  The check-boxes will be on another page and will track the progress of text box completion over time.

(The form is going to be used for an ongoing audit). 

If you know of a JavaScript / or how to do this - that would be greatly appreciated. Many thanks - Kind regards Kevin

TOPICS
Acrobat SDK and JavaScript , Windows
2.3K
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

correct answers 1 Correct answer

Community Expert , Nov 11, 2016 Nov 11, 2016

Sure, it's possible. Enter this code as the custom validation script of the text field:

this.getField("checkbox 1").checkThisBox(0, (event.value!=""));

You can set the check-box as read-only to prevent the user from changing its value manually.

Translate
Community Expert ,
Nov 11, 2016 Nov 11, 2016

Sure, it's possible. Enter this code as the custom validation script of the text field:

this.getField("checkbox 1").checkThisBox(0, (event.value!=""));

You can set the check-box as read-only to prevent the user from changing its value manually.

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 Beginner ,
Nov 14, 2016 Nov 14, 2016

Brilliant! really helpful - many thanks. 

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 Beginner ,
Nov 14, 2016 Nov 14, 2016

Oh- PS greatly appreciate if you can help me with this (similar question): How to make 'checkbox 1' tick when 'signature 1' is signed.  (I have tried to use previous script).  Appreciate thanks Kevin

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 Beginner ,
Nov 14, 2016 Nov 14, 2016

PPS please ignore - your script works perfectly on my second question also. Kind regards Kevin 

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 Beginner ,
Nov 15, 2016 Nov 15, 2016

Hi Try67,

Sorry to be a pain a variation on the above: Do you know if it is possible to have three text fields, and a check box, and the check box only ticks when all three text fields have had text entered? if so the JS for that would be fantastic. Appreciated - Kind regards Kevin

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 ,
Nov 15, 2016 Nov 15, 2016

The easiest way is to create another (hidden) text field and then enter this code as its custom calculation script:

var v1 = this.getField("Text1").valueAsString!="";

var v2 = this.getField("Text2").valueAsString!="";

var v3 = this.getField("Text3").valueAsString!="";

this.getField("checkbox 1").checkThisBox(0, (v1 && v2 && v3));

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 Beginner ,
Nov 15, 2016 Nov 15, 2016

Many thanks for the quick reply: I haven't been able to get this to work, the check box only ticks when I enter text for the three text boxes and the hidden text box.  Thanks Try67 - Anymore help greatly appreciated. Many Thanks Kevin

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 ,
Nov 15, 2016 Nov 15, 2016

The hidden text box doesn't play a role in this code... Can you share you file?

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 Beginner ,
Nov 15, 2016 Nov 15, 2016

Many thanks for your help, I have made a test document, how do I attach and send?

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 ,
Nov 15, 2016 Nov 15, 2016

Upload it to something like Dropbox, Google Drive, Adobe Cloud, etc., and post the link to it here.

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 Beginner ,
Nov 15, 2016 Nov 15, 2016

Thanks Try67 Link is here: Dropbox - TEST Document.pdf

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 ,
Nov 15, 2016 Nov 15, 2016

You didn't put the script where I said it should be placed.

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 Beginner ,
Nov 15, 2016 Nov 15, 2016

Thanks for looking at this so promptly.  I applied to 'Text4' which would be the hidden field. (I'm misinterpreting instructions).  Sorry can you tell me which field it would apply to? Thank-you this is so appreciated. Kevin.   

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 Beginner ,
Nov 15, 2016 Nov 15, 2016
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 Beginner ,
Nov 15, 2016 Nov 15, 2016
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 ,
Nov 15, 2016 Nov 15, 2016

You placed the code as a validation script, not a calculation script as advised. It will work when you change it.

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 Beginner ,
Nov 16, 2016 Nov 16, 2016

Thank-you!  George, and Try 67. 

This is brilliant. I'm extremely grateful for your time, and expertise.  It is perfect as it unchecks   if the form is updated also.

I do have another question (slight variation to above).. I'll post on this thread if OK.

Kind regards

Kevin

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 Beginner ,
Nov 16, 2016 Nov 16, 2016

Hi Again, I would be grateful - if you can also help me with this (variation to above):

Is it possible to have 4 text fields, which activate a check box if at least one of them have text entered?

The JS for that would be fantastic. (I'll put it in correct place)

Again - really appreciated - thanks Kevin

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 ,
Nov 16, 2016 Nov 16, 2016

Use this code:

var v1 = this.getField("Text1").valueAsString!="";

var v2 = this.getField("Text2").valueAsString!="";

var v3 = this.getField("Text3").valueAsString!="";

var v4 = this.getField("Text4").valueAsString!="";

this.getField("checkbox 1").checkThisBox(0, (v1 || v2 || v3 || v4));

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 Beginner ,
Nov 16, 2016 Nov 16, 2016
LATEST

Perfect! Many thanks.

I see some of the patterns in the JS - so this is definitely inspiring me to learn to a basic level.  I may have one last question ... if OK I'll post on this thread.

Thanks again

Kind regards Kevin

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