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

"bigarray[...] is null or not an object"

Status
Not open for further replies.

Pimonkey

Programmer
Apr 29, 2003
6
0
0
US
Okay, I am really having problems with this. The subject is the error I get when running the following function. I have found that it actually does recognize "bigarray[parseInt(tope[ i ])].split(',')[0]", because I have document.writen it. The problem seems to be += the string formate. (The function creates a top ten list of people, based on a large list of people included in another script file)
Other script file example:
var bigarray = new Array(1400);
bigarray[1] = "name ,1,2134,2,.124,.154";
...continues for all 1400 values.

function topeten() {
var tope = new Array;
var i,temp,j,k;
var plac=-1;
for (i=0; i < 10; i++) {
tope[ i ] = 0;
}
for (i=0;i < bigarray.length; i++) {
if (bigarray[ i ] != null) {
for (j=0; j <10;j++) {
if (bigarray[ i ].split(&quot;,&quot;)[3] > tope[j]) {
plac=j;
break; }
}
if (plac != -1) {
for (k=plac;k<10; k++) {
tope[k] = tope[k+1]; }
tope[plac] = bigarray[ i ].split(&quot;,&quot;)[1];
}
plac=-1;
}
}
var formate=&quot;&quot;;
for (i=0; i< 10;i++) {
formate += &quot;<tr><td align=center>&quot; + bigarray[parseInt(tope[ i ])].split(',')[0] + &quot;</td><td align=center>&quot; + bigarray[parseInt(tope[ i ])].split(',')[2] + &quot;</td><td align=center>&quot; + bigarray[parseInt(tope[ i ])].split(',')[3] + &quot;</td><td align=center>&quot; + bigarray[parseInt(tope[ i ])].split(',')[4] + &quot;</td><td align=center>&quot; + bigarray[parseInt(tope[ i ])].split(',')[5] + &quot;</td></tr>&quot;; //faults on this line
}
document.write(&quot;<table align=center><tr><td align=center><b>Player |</b></td><td align=center><b>Power |</b></td><td align=center><b>Change |</b></td><td align=center><b>Power Per Hour |</b></td><td align=center><b>% Increase</b></td></tr>&quot; + formate+ &quot;</table><br><center><input type=button onClick='history.go(-1)' value='Back'>&quot;);
}
 
well yes very strange
can you put an alert( bigarray[parseInt(tope[ i ])].split(',')[5] ) and see what it returns and also if actually that is null or not?by removing that part from ur code and trying
 
I have tried it and yes it does display the correct value.
 
Through heavy editing and blind guesses I have got it to work. The problem had to do with the top array, which had problems being undefined.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top