Solved

how do i get the data from this object

Posted on 2010-11-13
10
609 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 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

10 Experts available now in Live!

Get 1:1 Help Now