help pls on json..

Discussion in 'Javascript' started by shotokan99, Aug 16, 2007.

  1. shotokan99

    shotokan99 Guest

    i have this code:
    //-----------------------------------//
    var custrec={
    "customer":[
    {
    "id" : 123,
    "name": "joy"
    },
    {
    "id" : 555,
    "name": "ritchie"
    },
    {
    "id" : 666,
    "name": "xander"
    }
    ]
    }
    for(i=0; i<= 2; i++ ){
    cust= custrec.customer.name;
    id=custrec.customer.id;
    document.write(id+' '+cust+'<br/>');
    }

    //-------------------------------//

    on the for..loop i specified that it will loop until 2. is there a way
    for me to automatically determine the number of records (am i using
    the right term?) of custrec.cusomter . like a typrical
    array....myarray.length.

    tnx.
     
    shotokan99, Aug 16, 2007
    #1
    1. Advertising

  2. shotokan99 wrote:

    > on the for..loop i specified that it will loop until 2. is there a way
    > for me to automatically determine the number of records (am i using
    > the right term?) of custrec.cusomter . like a typrical
    > array....myarray.length.


    Sure, custrec.customer is an Array object so it has a property
    custrec.customer.length that you can use, just as with other arrays.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 16, 2007
    #2
    1. Advertising

  3. shotokan99

    shotokan99 Guest

    actually i tried it

    for(i=0; i <= custrec.customer.length; i++){
    ..
    ..
    ..
    }

    and its not working...
     
    shotokan99, Aug 17, 2007
    #3
  4. shotokan99 wrote:
    > actually i tried it
    >
    > for(i=0; i <= custrec.customer.length; i++){
    > .
    > .
    > .
    > }
    >
    > and its not working...


    "Does not work" is a useless error description. [psf 4.11]

    http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Aug 17, 2007
    #4
    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. Florian Frank
    Replies:
    0
    Views:
    267
    Florian Frank
    Jun 30, 2009
  2. sajuptpm
    Replies:
    2
    Views:
    410
    sajuptpm
    Dec 28, 2012
  3. Acácio Centeno
    Replies:
    1
    Views:
    313
    dieter
    Feb 15, 2013
  4. Bryan Britten
    Replies:
    9
    Views:
    301
    Bryan Britten
    May 28, 2013
  5. David Karr
    Replies:
    1
    Views:
    197
    David Karr
    Jun 17, 2013
Loading...

Share This Page