为了账号安全,请及时绑定邮箱和手机立即绑定

Acrobat 中的 Javascript - 无法将值传递出对话框

Acrobat 中的 Javascript - 无法将值传递出对话框

胡说叔叔 2022-10-13 16:43:30
    我在使用 Adobe Acrobat 中的自定义对话框时遇到了困难。我的目标是在您单击顶部工具栏中的按钮时出现一个对话框。该对话框将包含一个可编辑的文本字段和一个 list_box。输入文本后,从列表框中进行选择,然后单击“确定”,这些值将传递到 PDF 文档上的文本字段。现在我让他们的值返回到控制台。每次我尝试运行代码时,两个变量(一个用于文本字段条目,一个用于列表框选择)都返回未定义。我对 Acrobat 中的 javascript 非常陌生,所以这个项目就像一个由互联网上不同代码片段组成的科学怪人一样慢慢地走到了一起,哈哈。任何见解将不胜感激!var timeDialog = {    initialize: function(dialog) {this.loadDefaults(dialog);},        commit: function(dialog) {             var timeEntry = dialog.store()["tetb"]            var techEntry = dialog.store()["tnlb"]          },        loadDefaults: function (dialog) {            dialog.load({                "tnlb":                {                    "Jimmy John": +2,                    "Papa John": +1,                    "Great Gatsby": +0                }            })        },        description:         {            name: "Time Dedicated",             elements:             [                {                     type: "view",                      elements:                     [                        {                            type: "cluster",                            elements:                            [                                {                                    name: "Time spent on Request (minutes):",                                     type: "static_text"                                },                                {                                    type: "edit_text",                                    item_id: "tetb",                                    char_width: 5                                },                                {                                    name: "Technician:",                                     type: "static_text"                                },                    ]                }            ]        }    }}
查看完整描述

1 回答

?
慕神8447489

TA贡献1780条经验 获得超1个赞

看看我为你写的新提交函数。列表项存储为列表,其中具有正索引值的项是选定项。然后,您可以访问选定的值。


var timeDialog = {

    initialize: function (dialog) { this.loadDefaults(dialog); },

    commit: function (dialog) {

        this.timeEntry = dialog.store()["tetb"];

        var items = dialog.store()["tnlb"]

        for (var item in items) {

            if (items[item] > 0) {

                this.techEntry = item;

                break;

            }

        }

    },

    loadDefaults: function (dialog) {

        dialog.load({

            "tnlb":

            {

                "Jimmy John": +2,

                "Papa John": +1,

                "Great Gatsby": +0

            }

        })

    },

    description:

    {

        name: "Time Dedicated",

        elements:

            [

                {

                    type: "view",

                    elements:

                        [

                            {

                                type: "cluster",

                                elements:

                                    [

                                        {

                                            name: "Time spent on Request (minutes):",

                                            type: "static_text"

                                        },

                                        {

                                            type: "edit_text",

                                            item_id: "tetb",

                                            char_width: 5

                                        },

                                        {

                                            name: "Technician:",

                                            type: "static_text"

                                        },

                                        {

                                            item_id: "tnlb",

                                            type: "list_box",

                                            width: 200,

                                            height: 60

                                        }

                                    ]

                            },

                            {

                                type: "ok_cancel"

                            }

                        ]

                }

            ]

    }

}


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

    console.println(timeDialog.timeEntry);

    console.println(timeDialog.techEntry); 

}


查看完整回答
反对 回复 2022-10-13
  • 1 回答
  • 0 关注
  • 164 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号