如何解决Adobe Acrobat中的JavaScript语法错误?

发布于 2025-02-09 23:53:00 字数 2869 浏览 1 评论 0原文

我的任务是将我所工作的法院系统表格转换为可填写的PDF。根据“法庭”下拉列表中选择了哪些选择,我被要求进行“地址”字段自动填充。我对编码一无所知,所以我搜索了论坛,直到我找到了包含此代码的演练,

// Place all prepopulation data into a single data structure
var DeptData = { Accounting:{ contact: "Steala Damuni",
                              email: "[email protected]",
                              deptnum: "cmp1234" },
                 Engineering:{ contact: "Frank N. Stien",
                              email: "[email protected]",
                              deptnum: "eng1234" },
                 Marketing :{ contact: "Shelly Oughtbuks",
                              email: "[email protected]",
                              deptnum: "mkt1234" },
                 ITSupport:{ contact: "Goah  Wei",
                              email: "[email protected]",
                              deptnum: "its1234" }};
function SetFieldValues(cDeptName)
{
  this.getField("DeptContact").value = DeptData[cDeptName].contact;
  this.getField("DeptEmail").value = DeptData[cDeptName].email;
  this.getField("DeptNumber").value = DeptData[cDeptName].deptnum;
}

我尝试更改字段名称,以便它们匹配我的表格,并得到了这

var DeptData = { South Division Dept. 1:{ address: "20520 68th Ave. W. Lynnwood WA 98036"},
               South Division Dept. 2:{ address: "20520 68th Ave W Lynnwood WA 98036"},
               South Division Dept. 3:{ address: "20520 68th Ave. W. Lynnwood WA 98036"},
               South Division Dept. 4:{ address: "20520 68th Ave. W. Lynnwood WA 98036"},
               Cascade Division Dept. 1:{ address: "415 E Burke Ave. Arlington WA 98223"},
               Cascade Division Dept. 2:{ address: "415 E Burke Ave. Arlington WA 98223"},
               Evergreen Division Dept. 1:{ address: "14414 179th Ave SE Monroe WA 98272"},
               Evergreen Division Dept. 2:{ address: "14414 179th Ave SE Monroe WA 98272"},
               Everett Division Courtroom 3A:{ address: "3000 Rockefeller Ave Everett WA 98201"},
               Everett Division Courtroom 3B:{ address: "3000 Rockefeller Ave Everett WA 98201"},
               Everett Division Courtroom 3C:{ address: "3000 Rockefeller Ave Everett WA 98201" }};

function SetFieldValues(cCourtroom)
{
  this.getField("address").value = DeptData[cCourtroom].address;
  
}

件事,这是不断出现错误的内容,” Syntaxerror:Misssing:Misssing:Monsting:After Property ID之后1:在第2行中

I have been tasked with converting the forms for the court system I work for into fillable PDF's. I was asked to make the "address" field auto-populate depending on what choice was selected in the "Courtroom" dropdown list. I know nothing about coding so I searched forums until I found a walkthrough that contained this code

// Place all prepopulation data into a single data structure
var DeptData = { Accounting:{ contact: "Steala Damuni",
                              email: "[email protected]",
                              deptnum: "cmp1234" },
                 Engineering:{ contact: "Frank N. Stien",
                              email: "[email protected]",
                              deptnum: "eng1234" },
                 Marketing :{ contact: "Shelly Oughtbuks",
                              email: "[email protected]",
                              deptnum: "mkt1234" },
                 ITSupport:{ contact: "Goah  Wei",
                              email: "[email protected]",
                              deptnum: "its1234" }};
function SetFieldValues(cDeptName)
{
  this.getField("DeptContact").value = DeptData[cDeptName].contact;
  this.getField("DeptEmail").value = DeptData[cDeptName].email;
  this.getField("DeptNumber").value = DeptData[cDeptName].deptnum;
}

I tried changing the field names so they would match my form and got this

var DeptData = { South Division Dept. 1:{ address: "20520 68th Ave. W. Lynnwood WA 98036"},
               South Division Dept. 2:{ address: "20520 68th Ave W Lynnwood WA 98036"},
               South Division Dept. 3:{ address: "20520 68th Ave. W. Lynnwood WA 98036"},
               South Division Dept. 4:{ address: "20520 68th Ave. W. Lynnwood WA 98036"},
               Cascade Division Dept. 1:{ address: "415 E Burke Ave. Arlington WA 98223"},
               Cascade Division Dept. 2:{ address: "415 E Burke Ave. Arlington WA 98223"},
               Evergreen Division Dept. 1:{ address: "14414 179th Ave SE Monroe WA 98272"},
               Evergreen Division Dept. 2:{ address: "14414 179th Ave SE Monroe WA 98272"},
               Everett Division Courtroom 3A:{ address: "3000 Rockefeller Ave Everett WA 98201"},
               Everett Division Courtroom 3B:{ address: "3000 Rockefeller Ave Everett WA 98201"},
               Everett Division Courtroom 3C:{ address: "3000 Rockefeller Ave Everett WA 98201" }};

function SetFieldValues(cCourtroom)
{
  this.getField("address").value = DeptData[cCourtroom].address;
  
}

Thing is it keeps throwing up an error, "SyntaxError: missing : after property id 1: at line 2"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你在我安 2025-02-16 23:53:00

您的对象键有空格,您需要将它们放入这样的报价中:

var DeptData = {
  "South Division Dept. 1": {
    address: "20520 68th Ave. W. Lynnwood WA 98036"
  },
  "South Division Dept. 2": {
    address: "20520 68th Ave W Lynnwood WA 98036"
  },
  "South Division Dept. 3": {
    address: "20520 68th Ave. W. Lynnwood WA 98036"
  },
  "South Division Dept. 4": {
    address: "20520 68th Ave. W. Lynnwood WA 98036"
  },
  "Cascade Division Dept. 1": {
    address: "415 E Burke Ave. Arlington WA 98223"
  },
  "Cascade Division Dept. 2": {
    address: "415 E Burke Ave. Arlington WA 98223"
  },
  "Evergreen Division Dept. 1": {
    address: "14414 179th Ave SE Monroe WA 98272"
  },
  "Evergreen Division Dept. 2": {
    address: "14414 179th Ave SE Monroe WA 98272"
  },
  "Everett Division Courtroom 3A": {
    address: "3000 Rockefeller Ave Everett WA 98201"
  },
  "Everett Division Courtroom 3B": {
    address: "3000 Rockefeller Ave Everett WA 98201"
  },
  "Everett Division Courtroom 3C": {
    address: "3000 Rockefeller Ave Everett WA 98201"
  }
};

Your object keys have spaces, you need to put them into quotes like this:

var DeptData = {
  "South Division Dept. 1": {
    address: "20520 68th Ave. W. Lynnwood WA 98036"
  },
  "South Division Dept. 2": {
    address: "20520 68th Ave W Lynnwood WA 98036"
  },
  "South Division Dept. 3": {
    address: "20520 68th Ave. W. Lynnwood WA 98036"
  },
  "South Division Dept. 4": {
    address: "20520 68th Ave. W. Lynnwood WA 98036"
  },
  "Cascade Division Dept. 1": {
    address: "415 E Burke Ave. Arlington WA 98223"
  },
  "Cascade Division Dept. 2": {
    address: "415 E Burke Ave. Arlington WA 98223"
  },
  "Evergreen Division Dept. 1": {
    address: "14414 179th Ave SE Monroe WA 98272"
  },
  "Evergreen Division Dept. 2": {
    address: "14414 179th Ave SE Monroe WA 98272"
  },
  "Everett Division Courtroom 3A": {
    address: "3000 Rockefeller Ave Everett WA 98201"
  },
  "Everett Division Courtroom 3B": {
    address: "3000 Rockefeller Ave Everett WA 98201"
  },
  "Everett Division Courtroom 3C": {
    address: "3000 Rockefeller Ave Everett WA 98201"
  }
};

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文