How do I use a variable imported from a cvs document in a hyperlink in html?

  Kiến thức lập trình

I’m very new to html and I just can’t figure this out! I’ve tried a ton of searching online and on here but I can’t make anything work!

I’ve been using code from a tutorial that inputs data from a csv file and uses it in the popup boxes on a map. I want the urls from that file to be clickable in the popup boxes but I can’t figure out how to do it. It seems like it should be possible! (Sorry if my formatting is wrong this is my first time asking a question here.)

// For example: e.features[0].properties.Name is retrieving information from the field Name in the original CSV.
var site = e.features[0].properties.Website;
var description = `<h3>` + e.features[0].properties.Name + `</h3>` + `<h4>` + `<b>` + `Address: ` + `</b>` + e.features[0].properties.Address + `</h4>` + `<h4>` + `<b>` + `Category: ` + `</b>` + e.features[0].properties.Tags + `</h4>` + `<h4>`  + `<b>` + `Website: ` + `</b>` + e.features[0].properties.Website +  `</h4>` + `<h4>`  + `<b>` + `Further Information: ` + `</b>`+ `</h4>` + `<h4>`+ <a href="site">TESTLINK</a>` + `</h4>`;

I’ve tried using onclick in the href tags like in this example: (Link to <a href=”https:www.google.com/”onclick=”location.href=this.href+’?xyz=’+val;return false;”>Google) but it keeps saying my variable is undefined. Also I’m not actually sure how to modify this to just take a url!

New contributor

user24719814 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT