Select to view content in your preferred language

How to retrieve all the fields from a layer after clicking identify in Javascript

497
1
12-29-2011 07:51 AM
QaziIqbal
Deactivated User
I am using identify onclick. I am able to get the attributes only with their specific names like
idResult.feature.attributes['FACIL_ID']

I want to retrieve all the fields and values from the attribute table of the layer.
Thanks
Qazi Iqbal
0 Kudos
1 Reply
HemingZhu
Frequent Contributor
I am using identify onclick. I am able to get the attributes only with their specific names like
idResult.feature.attributes['FACIL_ID']

I want to retrieve all the fields and values from the attribute table of the layer.
Thanks
Qazi Iqbal


for a demo. use the following code:
var fields =[];
var fieldName;
for (attribute in idResult.feature.attributes)
{
    fields.push(attribute);
} 
for(var i=0; i<fields.length; i++)
{
    fieldName =fields;
    // field name
    alert(fieldName);
    // field value
    alert(idResult.feature.attributes[fieldName]);
}
0 Kudos