Passing in Field Name of evt.graphic.attributes

3171
2
Jump to solution
06-29-2015 12:07 PM
KeithAnderson
New Contributor III

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
New Contributor III

Thank you Robert!

0 Kudos