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

Popup window with checkbox written in Javascript

Explorer ,
Jan 19, 2017 Jan 19, 2017

Hello,

Task of the checkboxes in the popup window is to write the checkbox values to File > Properties > Description > Title.

If you selected 2 checkboxes, a ";" should be a separator between the 2 fields in the File > Properties > Description > Title field.

If you select only 1 checkbox, there is NO ; at all.

If you select 3 checkboxes, the separator is always a ; (in this case 2 times a ; )

This is one of my tries, hope that some freaks can help me.

I need also to exand the checkboxes until 9 different checkboxes.

var dialog2 =

    {

        initialize: function(dialog) {

            // Set a default value for radio button field

            dialog.load({"ckb1": true });

        },

        commit: function(dialog) {

            // When the user presses "Ok", this handler will execute first

            var results = dialog.store();

        },

        // The dialog box description

        description:

        {

            name: "More Personal Information",

            elements:

            [

                {

                    type: "view",

                    align_children: "align_left",

                    elements:

                    [

                        {

                            type: "static_text",

                            name: "Personal Information",

                            bold: true,

                            font: "dialog",

                            char_width: 30,

                            height: 20

                        },

                        {

                            type: "check_box",

                            item_id: "ckb1",

                            name: "Pet Owner"

                        },

                                                {

                            type: "check_box",

                            item_id: "ckb2",

                            name: "Pet Owner test"

                        },

                                                                        {

                            type: "check_box",

                            item_id: "ckb3",

                            name: "Pet Owner test"

                        },

                       

                    ]

                },

                {

                    type: "gap",    //Add a small vertical gap between

                    height: 10      //check boxes and buttons

                },

                {

                    type: "ok_cancel",

                    ok_name: "Ok",

                    cancel_name: "Cancel"

                }

            ]

        }

    };

this.info.author=""

if ("ok"==app.execDialog(dialog2)){

    this.info.title=dialog2.results

};

Examples

checkbox 1 and 2 selected results in: Pet Owner;Pet Owner test

checkbox 1 selected results in: Pet Owner

checkbox 1 and 2 and 3 selected results in: Pet Owner;Pet Owner test;Pet Owner test

No checkbox selected results in: <<empty field>>

TOPICS
Acrobat SDK and JavaScript
3.8K
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 , Jan 19, 2017 Jan 19, 2017

You're not really doing anything in the commit function. Use this code instead:

commit: function(dialog) {

    // When the user presses "Ok", this handler will execute first

    var results = dialog.store();

    var tickedItems = [];

    if (results["ckb1"])

        tickedItems.push("Pet Owner");

    if (results["ckb2"])

        tickedItems.push("Pet Owner test1");

    if (results["ckb3"])

        tickedItems.push("Pet Owner test2");

    this.results = tickedItems.join(";");

},

Translate
Explorer ,
Jan 19, 2017 Jan 19, 2017

Additional info.

Now there is no info written at all to Properties of the files. So there are some additional bugs in my code to solve.

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 ,
Jan 19, 2017 Jan 19, 2017

You're not really doing anything in the commit function. Use this code instead:

commit: function(dialog) {

    // When the user presses "Ok", this handler will execute first

    var results = dialog.store();

    var tickedItems = [];

    if (results["ckb1"])

        tickedItems.push("Pet Owner");

    if (results["ckb2"])

        tickedItems.push("Pet Owner test1");

    if (results["ckb3"])

        tickedItems.push("Pet Owner test2");

    this.results = tickedItems.join(";");

},

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
Explorer ,
Jan 19, 2017 Jan 19, 2017
LATEST

Mission accomplished! Thank you for helping try67!

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