I was using the wrong brackets.() not [] Working fine now.
Thanks for your help. On Oct 30, 3:09 pm, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > Hi, > > > var arrpeople = transport.responseText.evalJSON(true); > > alert(arrpeople.name); //this line doesn't fail but It > > returns 'Undefined' > > You're getting back an array, right? Just because it only has one > entry, doesn't make it less of an array. So you have to index into it > for the record you want. > > alert(arrpeople[0].name); > > HTH, > -- > T.J. Crowder > tj / crowder software / com > > On Oct 29, 5:02 pm, gedm <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm new to JSON and prototype so you may need to dumb it down a bit > > for me. I am using the JSON for ASP code to return a recordset in > > JSON format. It is only returning one record, which is correct for the > > query I am running, but the JSON for ASP class is putting the [ ] at > > each end of the data resulting in an array of data with 1 member. > > > How can I pass this via evalJSON in prototype. I want to retrieve the > > values of the JSON data and fill some form fields but can't figure out > > how to access the array. That is: data as follows > > [ {"name":"John","surname":"Smith"}] > > > how do I access the name and the surname? > > > var arrpeople = transport.responseText.evalJSON(true); > > alert(arrpeople.name); //this line doesn't fail but It > > returns 'Undefined' > > > Firebug shows the evalJSON has worked because I can drill down into > > arrpeople... 0... name and it shows John. What is the correct syntax > > to show arrpeople(0).name ? > > > Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---