Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to browse a 2 dimensions associatif Array ?

    Hello,

    I load a 2 dimensions javascript Array from an API. Let's say the array is called tab_int.
    So, first, there are declarations like :
    tab_int new = Arrray() ;
    tab_int['x'] = new Array() ;

    So I mean that :
    _ tab_int['x'] is an associatif Array
    _ tab_int is a 2 dimensions array - and even 2 dimensions associatif, because of the way I use it ...
    So there are some functions using this tab without problems with some tab_int['x']['z'] - actually 'x' and 'z' are in variables most part of the time

    Apart from one function ... of course (!), the function where I need to browse the entire table :

    Code:
    for ( var myInt in tab_int['x'] ) { if (tab_int['x'][myInt] != '' ) { // processing } }
    I have some really funny results, not stable, not secure, which makes me wonder if I'm on the good way !
    Sometimes I can go inside the loop (the first time, for example) but then I can't ... ?
    So : does that work ? is there something to re-initialize ? does anyone of you can make this kind of things work ?

    Thank you by advance for any clue ...
    Ben

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just be sure to realize the distinction between setting array properties and nesting arrays... tab_int['x'] becomes a property of tab_int, rather than an array item.
    *this message will self destruct in n-seconds*

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh yes ! you're right the "for ... in" has to be used with objects, but I thought it could be one way to go around this difficulty : how can I make to browse an associatif Array, how ever be the dimension of this array ?
    Thank you by advance


  •  

    Posting Permissions

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