Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to resolve a JavaScript Syntax Error in adobe acrobat?

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: "accounting@mycomp.com",
                              deptnum: "cmp1234" },
                 Engineering:{ contact: "Frank N. Stien",
                              email: "engineering@mycomp.com",
                              deptnum: "eng1234" },
                 Marketing :{ contact: "Shelly Oughtbuks",
                              email: "marketing@mycomp.com",
                              deptnum: "mkt1234" },
                 ITSupport:{ contact: "Goah  Wei",
                              email: "it@mycomp.com",
                              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"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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" }};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading