Inserting URL Into Javascript Loop

Discussion in 'Javascript' started by @excite(me).com, Jul 4, 2003.

  1. 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.
     
    @excite(me).com, Jul 4, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wjer
    Replies:
    0
    Views:
    2,030
  2. Brian Bush
    Replies:
    4
    Views:
    99
    Tim Hunter
    May 24, 2009
  3. Todd
    Replies:
    0
    Views:
    128
  4. Replies:
    7
    Views:
    110
  5. Isaac Won
    Replies:
    9
    Views:
    390
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page