Multi dimensioned array problem.

# Thread: Multi dimensioned array problem.

1. Member
Join Date
Dec 1969
Posts
87

## Multi dimensioned array problem.

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## JS doesn't HAVE multidim arrays!

So these two lines:<BR>&nbsp; &nbsp; var cde = new Array(adtc,cntc);<BR>&nbsp; &nbsp; var nbr = new Array(adtc,cntc);<BR>are each creating an array with TWO ELEMENTS only! Go look in the JS docs to see why.<BR><BR>JavaScript (and Java and C and C++) has *ONLY* single dimensional arrays. In order to get the *effect* of a multidimensional array, you must store an "inner" array in each element of the "outer" array. <BR><BR>So, for example:<BR>&nbsp; &nbsp; var outer = new Array(4)<BR>&nbsp; &nbsp; for ( var ix = 0; ix &#060; 4; ++ix ) outer[ix] = new Array(7);<BR><BR>And *now* you can do <BR>&nbsp; &nbsp; outer[row][column] = someValue;<BR><BR>Notices that I did not (and you can not) code <BR>&nbsp; &nbsp; outer[row,column]<BR><BR>SO... Time to go get a good reference or tutorial on JavaScript and re-learn how to do this.<BR><BR>But let me let you in on a couple of other "secrets": <BR><BR>(1) JS doesn&#039;t *require* that you specify the size of the array. If you create it too small, it will grow, automatically. (This isn&#039;t terribly important to you, but file it away.)<BR><BR>(2) The most efficient way to initialize a JS array is the same way you would do it in VBS, essentially:<BR>&nbsp; &nbsp; var ads = new Array( &#060;%Request.Form("ads_0") &","&Request.Form("ads_1")&","&....%&#062; );<BR><BR>You might want to think about how you could create that initialization easily, from ASP code. HINT: Think of doing <BR>&nbsp; &nbsp; &nbsp; Join(ads_array,"&#039;,&#039;")<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•