MultiDimensional Array

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

  1. janetb

    janetb Guest

    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
    #1
    1. Advertising

  2. janetb

    janetb Guest

    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
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Bazell

    slice of multidimensional array

    Dave Bazell, Jul 23, 2003, in forum: Perl
    Replies:
    2
    Views:
    4,106
  2. epigram
    Replies:
    1
    Views:
    10,862
    =?Utf-8?B?c29jaWV0b3BpYS5uZXQ=?=
    Jul 16, 2005
  3. Ben
    Replies:
    8
    Views:
    12,805
    Eki Y. Baskoro
    Dec 18, 2003
  4. Huub
    Replies:
    6
    Views:
    623
  5. geletine
    Replies:
    12
    Views:
    21,730
    Fred Kleinschmidt
    May 5, 2006
Loading...

Share This Page