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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Limits

Status
Not open for further replies.

Pauli

Programmer
Sep 25, 2000
2
US
I am trying to build a large array with over 2,000 records to populate a set of drop down lists. They will be used when a user selects a state, a related list of cities will populate a second drop down list dynamically. The problem is that I can't seem to get the 2000 cities into an array without the stack overflow. Is there a way around this? Or do I need to start fooling around with multidimensional arrays? One last question, why does the O'Reilly book 'Javascript Application Cookbook' claim that you can load thousands of records into an array from a static text file that is delimited correctly? Is this just a bunch of kaka or what?

Frustrated! [sig][/sig]
 
It's not the sytax (I believe). But rather just the number of records I am trying to load into an array. The syntax is like the following:

var cci_records = new Array(
'995|AK|ANCHORAGE',
'996|AK|ANCHORAGE',
'997|AK|FAIRBANKS',
'998|AK|JUNEAU',
'999|AK|KETCHIKAN',
'362|AL|ANNISTON',
'350|AL|BIRMINGHAM',...(continuing for another 2000 records)

If I shorten the list to about 150 or so, I can load the array, otherwise, I get the error. I have been able to load the data using multidimensional arrays, but I was wondering if anyone can answer the above question regarding the limits on the number of records. Is there really a 99 limit?


[sig][/sig]
 
Just a hunch, but try using full (") quotes instead of single quotes.

Something is going wrong with either your data, your delimiting or your syntax. I have a script ( ) that creates several arrays, each over 300 items long, and there is no memory problem. It even does looping calculations to make some of the arrays.

That page uses Javascript to calculate distance in spherical coordinates based on Latitude and Longitude entered. It loads the script and the data from an external file.

In fact, looking at your sample data, I suggest try splitting up your data into 3 arrays, because it looks like you are loading 3 fields worth of data into each iteration.

Your arrays would look like:
Code:
   cci_num = new Array(995,996,997, etc...);
   // No quotes here; this gives you the benefit of true  
   // numerical data for indexing--especially if they are unique numbers

   cci_state = new Array("AK","AK", etc...);

   cci_city = new Array("ANCHORAGE","ANCHORAGE","FAIRBANKS", etc...);
[sig][/sig]
 
you could definetly read the file with server side js
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top