?
Solved

how do i get the data from this object

Posted on 2010-11-13
10
Medium Priority
?
616 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 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