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

PDF form: Pass/print value to different text boxes based on users selection (mouseclick)

New Here ,
Sep 05, 2024 Sep 05, 2024

Copy link to clipboard

Copied

I would like to implement a function on a PDF form with scripts that allows me to make entries in text fields that the user clicks on via check boxes.

Example:

User clicks on/into Textbox A, and selects Checkbox Y, a value is printed into Textbox A, afterwards he clicks on /into Textbox B, and selects Checkbox Y again (or another checkbox) a value is printed into Textbox B and so on.

Thanks so much for any advice!

TOPICS
JavaScript , PDF forms

Views

62

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 Expert ,
Sep 05, 2024 Sep 05, 2024

Copy link to clipboard

Copied

LATEST

For multiple check boxes in a popup window you would have to use a popup dialog.  It's complicated.  Research the app method execDialog().

Enter the following script as a document level script:

function fillField()
{
var cb1="The text for check box 1";
var cb2="The text for check box 2";
var cb3="The text for check box 3";
var oDoc=this;
var fld=event.target;

var Dlg =
{
"Chk3": function(dialog)
{
var rslt=dialog.store();
if(rslt["Chk3"])
{dialog.end(fld.value=cb3);}
},
"Chk2": function(dialog)
{
var rslt=dialog.store();
if(rslt["Chk2"])
{dialog.end(fld.value=cb2);}
},
"Chk1": function(dialog)
{
var rslt=dialog.store();
if(rslt["Chk1"])
{dialog.end(fld.value=cb1);}

},
description:
{
name: "Dialog",
elements:
[
{
type: "view",
elements:
[
{
type: "check_box",
item_id: "Chk1",
name: cb1,
font: "dialog",
bold: true,
},
{
type: "check_box",
item_id: "Chk2",
name: cb2,
font: "dialog",
bold: true,
},
{
type: "check_box",
item_id: "Chk3",
name: cb3,
font: "dialog",
bold: true,
},
]
},
]
}
};
app.execDialog(Dlg)
}

This dialog has 3 check boxes.  You will need to modify the text in the quotes for cb1, cb2, and cb3 at the beginning of the script.  If you need more check boxes you can follow the pattern and add more.  Then, enter the following On Focus action script in any text field where you want this to populate:

fillField();

It's probably better to have a button to activate the dialog instead of an On Focus action.

Votes

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