Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does Array Exist??

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
I have an ASP page which dynamically creates javascript arrays and puts them in a SCRIPT section in the head of an HTML document. However, depending on different options the list of arrays created will not always be the same.

I have other code which runs on that page and I will need to be able to tell which arrays exist. Is there any way I can check if a certain array exists?

Mighty
 
In Javscript you can test if it exists like this.
Assume array name is myArr.

Code:
if (document.myArr)
  alert('myArr exists');

Or in your ASP code you can set flags to indicate if an array exists or set values to say WHICH arrays were created.
Or you could create all the arrays but not populate them and then test them in Javascript for their length. But I think the first example above will work for you.


At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top