亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Acrobat 中的 Javascript - 無法將值傳遞出對話框

Acrobat 中的 Javascript - 無法將值傳遞出對話框

胡說叔叔 2022-10-13 16:43:30
    我在使用 Adobe Acrobat 中的自定義對話框時遇到了困難。我的目標是在您單擊頂部工具欄中的按鈕時出現一個對話框。該對話框將包含一個可編輯的文本字段和一個 list_box。輸入文本后,從列表框中進行選擇,然后單擊“確定”,這些值將傳遞到 PDF 文檔上的文本字段?,F在我讓他們的值返回到控制臺。每次我嘗試運行代碼時,兩個變量(一個用于文本字段條目,一個用于列表框選擇)都返回未定義。我對 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 關注
  • 114 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號