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

Javascript for text box to auto populate from a check box

New Here ,
Apr 16, 2024 Apr 16, 2024

I have a form with a Yes check box and a No check box. 

When the user checks No, I would like the text box beside it to autopopulate to read "Not Applicable".

When the user checks Yes, I would like the text box to be free flow text entry.

I am stuck on the javascript to accomplish this. Also, does the script go into the properties of the checkbox or into the text box? 

Using Adobe Acrobat X Standard

TOPICS
Acrobat SDK and JavaScript
203
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 , Apr 16, 2024 Apr 16, 2024

To get started read this article:

https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm

 

Basically, you want to use the MouseUp action to run a script that will set the value of the text field when checked, and make it read only,  but when uncheck, clear the field and make it not readonly.

 

var oTxtFld = this.getFeild("TextField");

if(event.target.value == "Off")

{//Unchecked

     oTxtFld.readonly = false;

     oTxtFld.value = "";

}

else

{

     oTxtFld.readonly = true;

     oTxt

...
Translate
Community Expert ,
Apr 16, 2024 Apr 16, 2024
LATEST

To get started read this article:

https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm

 

Basically, you want to use the MouseUp action to run a script that will set the value of the text field when checked, and make it read only,  but when uncheck, clear the field and make it not readonly.

 

var oTxtFld = this.getFeild("TextField");

if(event.target.value == "Off")

{//Unchecked

     oTxtFld.readonly = false;

     oTxtFld.value = "";

}

else

{

     oTxtFld.readonly = true;

     oTxtFld.value = "Not Applicable";

}

 

      

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