Skip to main content
Participant
November 24, 2020
Question

SyntaxError Missing : after property id 2: line 3

  • November 24, 2020
  • 1 reply
  • 1623 views

I am trying to populate hopital phone fax and secondary fax based on a hospital the user selects.

EXAMPLE:

HN = HOSPITAL NAME

HP =  HOSPITAL PHONE

HF = HOSPITAL FAX

HF2 = HOSPITAL FAX 2

 

I have tried every single way to get this correct and I keep getting the same SyntaxError.

What am I doing wrong? Help is much appreciated at this point.

 

// Place all pre-population data into a single data structure
var HNData = { ADVNETIST HINSDALE:{ HP: "630-856-9000", HF: "630-856-8599", HF2: "N/A" }, ADVENTIST LAGRANGE MEMORIAL HOSPITAL:{ HP: "708-352-1200", HF: "708-856-8516", HF2: "N/A" }};
function SetFieldValues(cHN) {
// Populate fields with values from the Department Data Object
this.getField("HP").value = DeptData[cHN].HP;
this.getField("HF").value = DeptData[cHN].HF;
this.getField("HF2").value = DeptData[cHN].HF2;

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
November 24, 2020

Object member names cannot contain spaces or special characters, unless they are quoted. The quotes tell the script parser that it's all one thing. Otherwise the spaces cause the parser to interpret the text as separate things, which isn't allowed in this context. 

Here is the correct syntax:

 

var HNData = { "ADVNETIST HINSDALE":{ HP: "630-856-9000", HF: "630-856-8599", HF2: "N/A" }, "ADVENTIST LAGRANGE MEMORIAL HOSPITAL":{ HP: "708-352-1200", HF: "708-856-8516", HF2: "N/A" }};

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often