如何解决Adobe Acrobat中的JavaScript语法错误?
我的任务是将我所工作的法院系统表格转换为可填写的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的对象键有空格,您需要将它们放入这样的报价中:
Your object keys have spaces, you need to put them into quotes like this: