我的任務是將我作業的法院系統的表格轉換為可填寫的 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: missing : after property id 1: at line 2”
uj5u.com熱心網友回復:
您的物件鍵有空格,您需要將它們放在引號中,如下所示:
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" }};
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/494986.html
標籤:javascript 土坯 杂技演员
