Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add the data from a JSON file in a mailto link?

I am an absolute beginner with JS, looking to solve the following problem:

Context:

I have a JSON file with personal data like name, email address, bio, etc. For my project, I need to create a simple web page with all this personal data nicely presented per each individual (loading my data using $.getJSON()). I have to use JS, html and css combined to format the page.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Problem:

How do I add a mailto link to each email address on my page? It should open the correct email address for each individual, as per my JSON file. Here is my code so far:

 var email = "<p>" + candidatesDataset.results[i].email+ "</p>"; 


var person =
  '<section class="row" id="person"><div class="four columns card">' +
  image + '</div><div class="eight columns card">'+
  name + 
  about +
  email +
  "</div></section>";

The code above only shows the email address as text, while I need it to be clickable. Could someone please explain how to do this?

>Solution :

Do you mean :

var email = "<p><a href='mailto:"+ candidatesDataset.results[i].email+"'>" + candidatesDataset.results[i].email+ "</a></p>"; 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading