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(","
[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(","
[1];
}
plac=-1;
}
}
var formate="";
for (i=0; i< 10;i++) {
formate += "<tr><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[0] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[2] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[3] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[4] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[5] + "</td></tr>"; //faults on this line
}
document.write("<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>" + formate+ "</table><br><center><input type=button onClick='history.go(-1)' value='Back'>"
;
}
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(","
plac=j;
break; }
}
if (plac != -1) {
for (k=plac;k<10; k++) {
tope[k] = tope[k+1]; }
tope[plac] = bigarray[ i ].split(","
}
plac=-1;
}
}
var formate="";
for (i=0; i< 10;i++) {
formate += "<tr><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[0] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[2] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[3] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[4] + "</td><td align=center>" + bigarray[parseInt(tope[ i ])].split(',')[5] + "</td></tr>"; //faults on this line
}
document.write("<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>" + formate+ "</table><br><center><input type=button onClick='history.go(-1)' value='Back'>"
}