# MultiDimensional Array

Discussion in 'ASP General' started by janetb, Dec 9, 2004.

1. ### janetbGuest

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.

janetb, Dec 9, 2004

2. ### janetbGuest

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

"janetb" wrote:

> 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.
>
>

janetb, Dec 13, 2004