Solved

how do i get the data from this object

Posted on 2010-11-13
10
611 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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
 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

813 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

19 Experts available now in Live!

Get 1:1 Help Now