Referencing JavaScript Multidimensional Array

Results 1 to 2 of 2

Thread: Referencing JavaScript Multidimensional Array

  1. #1
    Join Date
    Dec 1969

    Default Referencing JavaScript Multidimensional Array

    How do you reference elements in the rsQarray array? The code runs on the server in an ASP file. The object rsQ is a recordset object returned from a MS Access query.<BR><BR>var rsQarray = rsQ.GetRows();<BR><BR>The Visual InterDev watch window shows:<BR>┬*┬*┬*┬*┬*Name┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬* ┬*┬*┬*┬*┬*┬*┬*┬*┬*Value┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*T ype<BR>┬*┬*┬*-rsQarray┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬* ┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*Array of Variant<BR>┬*┬*┬*┬*┬*┬*┬*-rsQarray[0]┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬* ┬*┬*┬*┬*┬*Array of Variant<BR>┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*-rsQarray[0][0]┬*┬*"John Smith"┬*┬*┬*┬*String<BR>┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*┬*-rsQarray[0][0]┬*┬*"Steve Jobs"┬*┬*┬*┬*String<BR>┬*┬*┬*┬*┬*┬*┬*+rsQarray[1]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+rsQ array[2]<BR>and so on. Everything is there, I just can&#039;t get to the values with code in the script. I have referenced several articles and found them to simple to be of help. I keep getting "undefined user type" and "rsQarray.0.1.1 is not an object" messages.<BR><BR>Any help would be appreciated.<BR>

  2. #2
    Join Date
    Dec 1969

    Default It is *NOT* a JS array!

    The problem is that ADODB.RecordSet.GetRows returns a VBS 2-D array! And that is *NOT* compatible with a JS array of any kind!<BR><BR>If you want to use that array from JS code, you have to convert it from the VBS array to a JS array.<BR><BR>Start here:<BR><BR><BR>Click on "Objects" in the list of categories.<BR><BR>Click on "VBArray Object" in the list of objects.<BR><BR>Read the docs, paying special attention to the example.<BR><BR>You can either use the "getItem" method to get elements of the VBArray or you can use the "toArray" method to convert the VBArray to a JS array, but note the docs there: If you do the latter, you end up with a ONE DIMENSIONAL JS array, so you have to use a little arithmetic to access the rows and columns of the original 2D array.<BR><BR>Yes, you *WOULD* think that *SOMEWHERE* in the MS docs there would be a discussion of this problem!<BR><BR>If you still need help with this, ask.<BR><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