Hyperlink within info-window using Attribute as link text

1401
1
04-15-2010 07:51 AM
MicahWilliamson
Occasional Contributor II
Well the title really says it all,

I currently have a infowindow that pops up after a query. I also currently have a working URL link within the attributes of that query.

The problem is that i want to combine two lines of the info window. I want to make the returned attribute a hyperlink.

Here is part of my infowindow code:

                    + "<br />County Board District: " + attr.CO_BOARD
                    + "<br />Board Member: " + attr.BRD_NAM
      + "<br /><a href=" + attr.URL + " target=_blank ;'>Meet Your Board Member</a>"

the link works fine but instead of  "Meet Your Board Member"  as the link text, i want it to be the attr.BRD_NAM

seems easy enough, but everything is different when you're working within the confines of JavaScript


any suggestions would be helpful and attempted.
If i figure it out before i get an answer, i'll post my findings.

thanks.
-MicahWilli
0 Kudos
1 Reply
MicahWilliamson
Occasional Contributor II
ESRI tech support supplied me with the correct syntax:

        //construct infowindow title and content
        var attr = feature.attributes;
        var title = attr.COUNTY_BRD;
        var content =  "<br /><i>County Offices</i>"
                + "<br />County Board District: " + attr.CO_BOARD
  +"<br>Board Member: <a href=" + attr.URL + " target=_blank ;'>"+ attr.BRD_NAM+"</a>"

here the URL field has the entire web address for that board member (no domains )
and BRD_NAM is the county board member's name.

So the result is dynamic, changing with each board member's district. 

*note the "attr" variable simply shortens the feature.attributes call so i don't have to type it out each time.
0 Kudos