Javascript variable names and ‘missing ; before statement’

So after being confused as to why I kept seeing the javascript error ‘missing ; before statement’, I realized that javascript variables can’t begin with a number.

My code was:

for (int i = 0; i < top; ++i) { eval("form." + fieldsArray[i] + ".value");
}

fieldsArray contains a string ‘0to99scans’ referring to a form input ‘0to99scans’. This should have been something like ‘zeroTo499scans’.

Leave a Reply

Your email address will not be published. Required fields are marked *