Skip to main content
Participant
September 24, 2020
Question

Help with Code Syntax error

  • September 24, 2020
  • 2 replies
  • 572 views

Can someone PLEASE, tell me where the error is in my code;

Here is the error:

SyntaxError: missing ] after element list
1: at line 2

 

Here is the code:

var fieldsToLock =["Name", "Student#:","Email:", "Phone#:", "Reference#:", Authorized by:", "Approved Amount","Approved Items:", "Price"]
[for (var i in fieldsToLock) this.getField(fieldsToLock[i]).readonly = true;]

 

I can't figure it out!

 

Thank you!

 

This topic has been closed for replies.

2 replies

Legend
September 24, 2020

You can also see a missing quote - one of the items in the list does not start with "

Lisa5E6FAuthor
Participant
September 25, 2020

Thank you for your eagle eye finding an issue. Thank you for your time.

BarlaeDC
Community Expert
Community Expert
September 24, 2020

Hi,

 

This line does not need to be in [] .

[for (var i in fieldsToLock) this.getField(fieldsToLock[i]).readonly = true;]

I would do it like this

 

for (var i =0; i < fieldsToLock.length; i++) {

this.getField(fieldsToLock[i]).readonly = true;

}

This covers agianst older versions of Adobe Acrobat and Reader being used.

 

Regards

 

Malcolm

Lisa5E6FAuthor
Participant
September 25, 2020

Wonderful....I was reaching beyond my skills...you saved my day. Thanks for your time.