I'm struggling with this, I am still new to javascript and am trying the jquery $.inarray function as I need to be able to find a value in an array so that I can return other values from the same array "line", such as its ID.
When I try to use jquery's inarray function, like this, I just get back -1, saying that it doesn't exist when I know the value exists, nested within the array.. I'm not sure of how to approach this so that I can search for a value, any advice is greatly appreciated.
valuereturn = $.inArray("search_for_value", jsonarray) ;
alert (valuereturn)
EDIT 2:
Here is the result of my echo'ing the JSON from cakephp:
{"getdata":[{"Uiemail":{"uiemail_id":"2","divid":"upd1","width":"200","height":"200","leftpos":"122","toppos":"122","cssgroup":"1","colortop":"","colorbottom":"","colorborder":"","borderwidth":"","zindex":""}},
{"Uiemail":{"uiemail_id":"3","divid":"upd2","width":"200","height":"200","leftpos":"333","toppos":"444","cssgroup":"1","colortop":"","colorbottom":"","colorborder":"","borderwidth":"","zindex":""}},
{"Uiemail":{"uiemail_id":"4","divid":"upd3","width":"200","height":"200","leftpos":"555","toppos":"466","cssgroup":"1","colortop":"","colorbottom":"","colorborder":"","borderwidth":"","zindex":""}}]}
EDIT:
Also, here is the output of:
alert(typeof jsonarray+'\n'+jsonarray.length)
output= "object 3 "
I tried this also, but it doesn't give a value and makes errors on my page:
alert(jsonararray)