Solved

how do i get the data from this object

Posted on 2010-11-13
10
613 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 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 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