Click to See Complete Forum and Search --> : unable to declare an array in include file


jScriptGuru
07-14-2003, 08:05 AM
Hi guys,

This line of code works fine if I use it inside a <script> tag in an asp page. ie use it inline..

But if i write same code in an include file, it gives me a syntax error

var myArray =_new_Array();

Pls help.

Thanks in advance.

requestcode
07-14-2003, 08:07 AM
For javascript it should be: var myArray = new Array();

jScriptGuru
07-14-2003, 09:05 AM
Thanks for that. Actually that is what I am writing. For some reason when i pasted the code in this window, it added underscores.. My code is..

var controlsNames = new Array();

This gives an error if it is put in an include file. Can you try.

Thanks again.

requestcode
07-14-2003, 09:35 AM
We need to see all of your code. It is possible that another line above that one is causing the problem. Can you give us a link?

jScriptGuru
07-14-2003, 10:02 AM
Hi RequestCode, I really appriciate your efforts in looking into the problem. To narrow the issue, i have just one line code in that include file.. this is what my test.js has

function test(){
var controlsNames=_new_Array();
}

When i include this file in my asp page, I get a syntax error. If i take off that array part and write

var controlsNames

then it works perfect..

Also, I want to mension that I get the syntax error on page load.. I mean, not on calling the function test() but on page load itself.

Thanks again.

jScriptGuru
07-15-2003, 07:38 AM
Guys. pls help.

Thanks so much