Find Task result as hyperlink in table

1971
2
Jump to solution
02-21-2016 09:17 AM
MeganWirth
Occasional Contributor

Having trouble formatting attribute as hyperlink in find task results table. can someone give me a hand with this?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ryan,

  Sure you just need to build your HTML Anchor element (line 23):

        //loop through each result in the response and add as a row in the table
        arrayUtils.forEach(response, function(findResult, i) {
          //Get each value of the desired attributes
          var subname = findResult.feature.attributes.NAME;
          var bookpage = findResult.feature.attributes[
            "BOOKANDPAGE"];
          var link = findResult.feature.attributes[
            "WEBURL"];
          var editor = findResult.feature.attributes[
            "EDITORNAME"];
          var date = findResult.feature.attributes[
            "last_edited_date"];

          //Add each resulting value to the table as a row
          var row = resultsTable.insertRow(i + 1);
          var cell1 = row.insertCell(0);
          var cell2 = row.insertCell(1);
          var cell3 = row.insertCell(2);
          var cell4 = row.insertCell(3);
          var cell5 = row.insertCell(4);
          cell1.innerHTML = subname;
          cell2.innerHTML = bookpage;
          cell3.innerHTML = "<a href=\"" + link + "\" target=\"_blank\">Web Link</a>";
          cell4.innerHTML = editor;
          cell5.innerHTML = date;
        });

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Ryan,

  Sure you just need to build your HTML Anchor element (line 23):

        //loop through each result in the response and add as a row in the table
        arrayUtils.forEach(response, function(findResult, i) {
          //Get each value of the desired attributes
          var subname = findResult.feature.attributes.NAME;
          var bookpage = findResult.feature.attributes[
            "BOOKANDPAGE"];
          var link = findResult.feature.attributes[
            "WEBURL"];
          var editor = findResult.feature.attributes[
            "EDITORNAME"];
          var date = findResult.feature.attributes[
            "last_edited_date"];

          //Add each resulting value to the table as a row
          var row = resultsTable.insertRow(i + 1);
          var cell1 = row.insertCell(0);
          var cell2 = row.insertCell(1);
          var cell3 = row.insertCell(2);
          var cell4 = row.insertCell(3);
          var cell5 = row.insertCell(4);
          cell1.innerHTML = subname;
          cell2.innerHTML = bookpage;
          cell3.innerHTML = "<a href=\"" + link + "\" target=\"_blank\">Web Link</a>";
          cell4.innerHTML = editor;
          cell5.innerHTML = date;
        });
MeganWirth
Occasional Contributor

Thanks Robert!

0 Kudos