Script help for "simple" Checkbox action to fill text box with specific script/sentence

New Here ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Annotation.pngI have scoured the forums and tried several different scripts and adapted them for my use successfully but I cannot seem to get this action for my checkbox on my form to work.

 

I am editing and updating a PDF form.

I have a checkbox named cbApproval.

When this box is checked, I would like the text field below it named ApprovalOnlyStatement to appear with the sentence "APPROVAL ONLY"

 

If the box is not checked, the text box should disappear and the user will need to move on to type in a justification in a larger text field underneath - probably not relevant information for this.

 

All I want is for the sentence to appear when the box is checked.  Help?

Thank you

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, PDF forms

Views

278

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 , Mar 18, 2020 Mar 18, 2020
This can be done with a single text field, and the script you'd use in the check box would be simpler. The Mouse Up script of the check box could be: // Mouse Up script of check box (function () { // Get a reference to the text field var f = getField("ApprovalOnlyStatement"); if (event.target.value === "Off") { f.value = ""; // Blank the statement field f.readonly = false; // Allow user to enter text } else { f.value = "APPROVAL ONLY"; // Set field ...

Likes

Translate

Translate
Adobe Community Professional ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

LATEST

This can be done with a single text field, and the script you'd use in the check box would be simpler. The Mouse Up script of the check box could be:

 

// Mouse Up script of check box
(function () {

    // Get a reference to the text field
    var f = getField("ApprovalOnlyStatement");

    if (event.target.value === "Off") {
        f.value = "";  // Blank the statement field
        f.readonly = false;  // Allow user to enter text
    } else {
        f.value = "APPROVAL ONLY";  // Set field text
        f.readonly = true;  // Don't allow user to enter text
    }

})();

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