MultiDimensional Array

J

janetb

I have the value of checkboxes coming into an asp page. All checkboxes have
the same name and the same number of values: e.g.

jid(1) = 1,4,38
jid(2) = 18,233,0
etc.

How do I put the above into multidimensional array that I can loop through
and call a stored procedure for populating a table?

dim ar(3)
y=0
for x=1 to request("jid").count
ar(y) = request("jid")(x)
y=y+1
next
for x=0 to Ubound(ar,2)
response.write ar(0,x) & "=" & ar(1,x) & "=" & ar(2,x) & "<br>"
next

Thanks a bunch.
 
J

janetb

This works - if anyone else needs it:

arArray1 = Split(str,",",-1,1) ' Split text into parts
iNum = UBound(arArray1) + 1 'Find the # of parts

If iNum Mod 3 = 0 Then
ReDim arArray2(2,iNum/3) ' Create 2D array
For iLoop = 0 To iNum - 1
' Place into correct indexes of the 2nd array
arArray2(iLoop Mod 3,Int(iLoop/3)) = arArray1(iLoop)
Next
End If

for x=0 to (iNum/3)-1
response.write "data1=" & arArray2(0,x) & ", data2=" & arArray2(1,x) & ",
data3=" & arArray2(2,x) & vbnewLine
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top