Inserting URL Into Javascript Loop

Hi -

This javascript was written by someone else and it is used to interact
with a Java applet, which draws a map on the screen. It bascially pulls
values from the applet and formats them as html so that the person
looking at the map can get attribute data about a point on the map.

I have modified the javascript to behave as I want it to behave, and it
works fine. The code below is not the entire script, but it is the
pertinent part.

Basically what the script does is pulls all of the attributes from the
map and then runs them through a loop to create an HTML table.

----------------

s2=
"<h3>Attribute Details</h3>";

var map = opener.document.mapApplet.getMap();

//get current layer
var lyrId = getParam("layerid");
var prj = map.getProject();
var lyr = prj.getLayerById(lyrId);
var ids = getParam("field_id")+",";
var s = "<TABLE border='1'><TR><TD>Heading 1</TD><TD>Heading 2</TD>";

var fieldCount = lyr.getFieldCount();

s = s + "</TR>";

while (ids.indexOf(",") > 0) {

var k = ids.indexOf(",");

var s3 = ids.slice(0, k);
ids = ids.slice(k+1);

var rec = lyr.findById(s3);

if(rec!=null){

s = s + "<TR>";

for(var j=0; j<fieldCount; j++){

s3 = rec.getField(j).toString();

if (s3=="") {
s3='&nbsp;';
}
s = s + "<TD>"+ s3+"</TD></TR>";

}
s = s +
"";
}

} //while

s2 = s2 + s + "</TABLE>";

----------------

Again, this works fine for me currently.

I would like to make one final modification, which I'm not able to
figure out.

Say for example that I want to add a hyperlink to the value returned
under "Heading 1". How would I go about doing that? It's not like I
could just do:

s = s + "<TD><A HREF='foo'>"+ s3+"</A></TD></TR>";

as then *all* of the results in the row would have the hyperlink
applied. Say I only want to add a hyperlink to one of the results, how
would I go about doing that?

Thanks.

Please only reply to the group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top