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

Php serialize and unserialize through form POST

php arrays serialization

I have set a number of hidden form inputs to have a value of a serialised array as shown in the example below: