Solved

how do i get the data from this object

Posted on 2010-11-13
10
610 Views
Last Modified: 2013-11-11
when I run this code
grid.getSelectionModel().on("rowselect",function(sm,idx,row){console.log(row);});
grid.getSelectionModel().on("rowselect",function(sm,idx,row){alert(row);});
the alert shows [object Object] the attached picture shows the console log
I don't know how to get the data element "city" out of the object - help would be appreciated.
0
Comment
Question by:twalker916
  • 6
  • 4
10 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 34127932
var city = data.CITY;

or

var city = data["CITY"];
0
 

Author Comment

by:twalker916
ID: 34128457
No that won't work - notice in the alert that data is an object with an object inside of it -  i will have to use a function of some kind to the interior object
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34128987
My code work for me...

(this is my screen copy of the object, it look like your as you can see)

Test page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script language="javascript">
var data = {"HOSPITAL":"Feather River Hospital","CITEDEFICENCY":["(Immediate Jeopardy) Ph...Risk of adverse events"],"CITY":"Paradise","COUNTY":"Butte","DAYS":"0"}
alert( data["CITY"] );
</script>
</body>
</html>

Open in new window

Clipboard02.jpg
0
 

Author Comment

by:twalker916
ID: 34131430
Look at the image I included - data is not an array - it is an object
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34132431
We've the same object/array.
Your question is :

how do i get the data from this object
I don't know how to get the data element "city" out of the object

I give you the code to get the city for example.

Check this too : http://www.quirksmode.org/js/associative.html
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:twalker916
ID: 34136744
I know you think that should work - it was the first thing I tried, but it does not work - data always comes back as undefined.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34137415
Could you confirm my test page don't work on your side.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34137418
Could you confirm my test page don't work on your side?
0
 

Author Closing Comment

by:twalker916
ID: 34141308
This is the correct solution - when I tried it I had city in lower case and that is why it did not work for me - thanks for your help
0
 
LVL 82

Expert Comment

by:leakim971
ID: 34141312
You're welcome! Thanks for the points!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now