Select to view content in your preferred language

Passing in Field Name of evt.graphic.attributes

3329
2
Jump to solution
06-29-2015 12:07 PM
KeithAnderson
Occasional Contributor

Folks

I am using

Layer.on("Click", function (evt){
var testval = evt.graphic.attributes.ADDRESS
}

to return the Feature value of the "ADDRESS" field.

testval results are fine.

My issue is I need to pass in a different Field each time a new FeatureLayer is activated.

I have the name of the Field prior to the on Click event.

What is the syntax....

fld = "NAME";

Layer.on("Click", function (evt){
var testval = "evt.graphic.attributes." + fld;
}

Alternative ideas welcome.

Thanks,

Keith

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Keith,

  Try:

fld = "NAME";  
  
Layer.on("Click", function (evt){  
var testval = evt.graphic.attributes[fld];  
}

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Keith,

  Try:

fld = "NAME";  
  
Layer.on("Click", function (evt){  
var testval = evt.graphic.attributes[fld];  
}
KeithAnderson
Occasional Contributor

Thank you Robert!

0 Kudos