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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with logic keys

    Hi. Have some troubles checking arrays length:
    Code:
    var holder = column = new Array ();
    column[0] = new Array ();
    column[0]["ID"] = 1;
    column[0]["TITLE"] = "Revistas";
    column[0]["DESCRIPTION"] = "Revistas Viejas";
    column[0]["PUBLICATION_DATE_DAY"] = 1;
    column[0]["PUBLICATION_DATE_MONTH"] = 1;
    ...
    
        for (var i=0; i < holder.length;i++) {
            if (holder[i].length) alert ("Voila!");
            ...
        }
    The fact is I cant get into holder inner arrays by referring its logic key. However, if I call ...
    Code:
    alert (holder[i]["ID"]);
    ... can see its value normally.
    What am I doing wrong?

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It looks like the array's length is 0, so... (properties are not array members, btw).
    Last edited by codegoboom; 03-14-2005 at 02:33 AM. Reason: 'members' meaning 'items'...
    *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
    Right. Length is 0. Array items have no properties. So, how do I loop them through?
    Last edited by stack13; 03-14-2005 at 03:25 AM.

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Use a 'for... in...' loop.
    *this message will self destruct in n-seconds*

  • #5
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok folks. The reason why I could not get through members is at the for statement. I should have used:
    Code:
        for (var i =0;i < holder.length;i++) {
            h = holder[i];
            for (var k in h) {
                alert (h[k]);
            }
        }


  •  

    Posting Permissions

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