Javascript: what is the $result.rows.item(x) variable type?

I had a function that reads displays the contents of the SELECT query coming from WEBSQL of HTML5. I want to reuse that function but I have the problem since what am I getting is an Array of JSON object and I want to convert it it rows.item() so do anyone know how that works?

Example, I have this JSON Array

"retdic":[{"row_index":0,"lname":"Mato","age":26,"gender":"M","pic":"cyborg.jpg","fname":"Shibiru"},
          {"row_index":1,"lname":"Taro","age":30,"gender":"M","pic":"folder_wrench.png","fname":"Ichigo"},
          {"row_index":2,"lname":"Joni","age":27,"gender":"M","pic":"naruto.jpg","fname":"Perez"},
          {"row_index":3,"lname":"Sakura","age":24,"gender":"F","pic":"folder_table.png","fname":"Haruka"},              
          {"row_index":4,"lname":"Naruto","age":20,"gender":"M","pic":"naruto.jpg","fname":"Uzumaki"}]

How can I convert it to like $result.rows.item()? item() is not an array right coz if it is an array it should be item[].

UPDATE

Using the idea and help of Jeff I figured out how to do it. See the live example

Answers


Ok, so assuming that the only difference between your array and the item() function is that one is an array and the other a function (I'm assuming that you use item() as "$result.rows.item(3)" to get the 4th row), is pretty simple. Just define a function which takes a parameter i and returns the item at index i in the array. So:

var myItemFunction = function(i) {
     return retdic[i]
}

Need Your Help

How can I have users upload multiple pictures like facebook?

php javascript jquery file-upload

How can I allow users to upload many images (code wise). I'm looking for plugins with examples or code examples.

Do I need to release xib resources?

iphone objective-c cocoa-touch

If I have something like a UILabel linked to a xib file, do I need to release it on dealloc of my view? The reason I ask is because I don't alloc it, which makes me think I don't need to release it

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.