/    Sign up×
Community /Pin to ProfileBookmark

Filling multidimensional arrays using ADO

I have a strange problem I can’t see a way around.

I have a large recordset (183 records and 89 fields). I want to do some dynamic things on a web page, as you do, but for some reason the array only fills with the last record. When you document.write the variables at various points in the while loop it looks fine, but when you try to write out the dataset again from the array, I only get the last record. 183 times!

Where is my stupid mistake!!!????

Here’s the code:

var svr; // Server object
var rst; // Recordset object

// Create a new Server and get all data.
svr = new ActiveXObject(“ADOVarietyData.ADOVarietyServer”);
rst = svr.DetailsForVarieties();
var arrFields = new Array();
var nRec = 0;
var x = 0;
rst.MoveFirst();
while (!rst.EOF) {
for (x = 0; x <= 89; x++){
arrFields[nRec,x] = rst.fields(x).value;
}
nRec++;
rst.MoveNext();
}
rst.close;

//LIST 1ST THREE RECORDS DATA
for (RecNo = 0; RecNo <= nRec; RecNo++){
for (nFieldNo = 0; nFieldNo <= 89; nFieldNo++){
if (RecNo <= 2){
document.write(arrFields[RecNo,nFieldNo] + “<br>”);
}
}
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@VladdyOct 08.2003 — that's not the way you do 2D arrays in Javascript
Copy linkTweet thisAlerts:
@MonkeyBoyauthorOct 08.2003 — I adapted the code from other code I had which worked (this combines VBScript and JavaScript). Here's a snippet:

do while not rsSpecies.eof
%>

x = <%= trim(y) %>

Insect = new Array();
GenusID = "<%= trim(rsSpecies("GenusID"))%>";
SpeciesID = "<%= trim(rsSpecies("SpeciesID"))%>";
SpeciesName = "<%= trim(rsSpecies("SpeciesName"))%>";

Insect[x,0] = GenusID;
Insect[x,1] = SpeciesID;
Insect[x,2] = SpeciesName;


That works, so why doesn't my new code. Please tell me how to fix this. Or tell me how you do do 2D arrays in Javascript coz I haven't found anything useful so far in my net searches.
Copy linkTweet thisAlerts:
@MonkeyBoyauthorOct 09.2003 — Bump.

Anyone got any ideas?
×

Success!

Help @MonkeyBoy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...