Published October 9, 2013 | https://doi.org/10.59350/7yj2v-4sz07

Programming in the Life Sciences #5: converting the results into HTML

Creators & Contributors

  • 1. ROR icon Maastricht University

Now that we have the communication working with the Open PHACTS LDA, it is time to make a nice GUI. I will not go into details, but we can use basic JavaScript to iterate over the JSON results, and, for example, create a HTML table:

In fact, I hooked in some HTML onClick() functionality so that when you click one of the compound names, you get further details (under Compound Details), though that only outputs the ConceptWiki URI at this moment. A simple for-loop does the heavy work:

html = "<table>";
for (var i=0; i<response.length; i++) {
  html += "<tr>";
  html += "<td>";
  dataJSON = JSON.stringify(response[i]);
  //   dataJSON.replace(/"/g, "'");
  html += "Name: <span>" + response[i].prefLabel + "</span>";
  html += "</td>";
  html += "</tr>";
}
html += "</table>";
document.getElementById("table").innerHTML = html;

So, we're set to teach the students all the basics of programming: loops, variables, functions, etc.

Additional details

Description

Now that we have the communication working with the Open PHACTS LDA, it is time to make a nice GUI.

Identifiers

UUID
d0811e7f-4969-4f55-8f58-4f1808cb03e6
GUID
https://doi.org/10.59350/7yj2v-4sz07
URL
https://chem-bla-ics.linkedchemistry.info/2013/10/09/programming-in-life-sciences-5.html

Dates

Issued
2013-10-09T00:00:00
Updated
2025-02-15T00:00:00