简体   繁体   English

Livecycle(JavaScript)代码未按顺序运行

[英]Livecycle (JavaScript) code not running in order

Good Afternoon, 下午好,

I am in the process of making a PDF form in Livecycle ES2 using JavaScript. 我正在使用JavaScript在Livecycle ES2中制作PDF表单。

I have created a button (Lockbutton1) on my form in the "click" event which uses the below code, to make all fields on several subforms “read only” and then prompt the user with a “Save As” box. 我使用以下代码在“单击”事件中的窗体上创建了一个按钮(Lockbutton1),以使几个子窗体上的所有字段均为“只读”,然后在“另存为”框中提示用户。

FORM.Page1.LockButton1::click - (JavaScript, client)

// Lock all fields in subforms except for signature subforms

oTargetField = this.resolveNode("SubformTop");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEP");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLN");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLNR");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEPR");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEPRD");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmDEPRI");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLNRD");
    oTargetField.access = "readOnly";
oTargetField = this.resolveNode("SubfrmLNRI");
    oTargetField.access = "readOnly";

// Hide other buttons and text

this.resolveNode("ResetButton1").presence = "invisible";
this.resolveNode("PrintButton1").presence = "invisible";
this.resolveNode("FormType").presence = "invisible";
this.resolveNode("$").presence = "invisible";
this.resolveNode("Splashtxt").presence = "invisible";

// Save the form
app.execMenuItem("SaveAs");

However, when the user clicks on the lock button, the user is first prompted with the “Save As” box and once the form is saved, then the rest of the code kicks off, making the subforms read only and hiding the buttons and text. 但是,当用户单击锁定按钮时,首先会提示用户“另存为”框,一旦保存了表单,其余代码便会启动,使子表单变为只读状态并隐藏按钮和文本。

I dont understand why the first thing to kick off is the "Save As" box, when this should be the last thing to kick off from within the code. 我不明白为什么首先要启动的是“另存为”框,而这应该是代码中最后要启动的东西。

I need the process to work in the below order: 我需要按以下顺序工作的过程:

  1. User clicks Lock button. 用户单击锁定按钮。
  2. Specified subforms are changed to read only. 指定的子窗体更改为只读。
  3. Buttons and text go invisible. 按钮和文本不可见。
  4. User is prompted with “Save As” box. 系统提示用户“另存为”框。

Anyone have any ideas what's happening and how I can fix? 任何人都知道发生了什么事以及如何解决?

Regards, 问候,

A 一种

Your code logic is OK. 您的代码逻辑还可以。 Check if all nodes have the same names as defined in LiveCycle. 检查所有节点的名称是否与LiveCycle中定义的名称相同。 See below a sample and the result: 参见下面的示例和结果:

代码样例

PDF结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM