I have read many posts on adding a javascript variable in html href including document.write and onclick but nothing seems to work.
I am working on google sheets script editor. My javascript url variables which are available in a script consists of client.linkedin (/.......), client.facebook (/.......)...
I would need in my html:<a href=client.linkedin > | LINKEDIN</a>
I have tried:
<a href="https://www.linkedin.com/" onclick="location.href=this.href+client.linkedin;return false;" > | LINKEDIN</a>
Starting with the javascript variable, I use a function which returns the info needed from google sheets in specific cell:
var client = {
role: Getinfo("person1"),
linkedin: Getinfo("person1"),
number : Getinfo("person1"),
};
var templ = HtmlService.createTemplateFromFile('HTMLFILE');
templ.client = client;
Therefore, the linkedin URL would change for every person. Going to the html file, what I usually did was:
<p> <strong><?= client.linkedin ?> </strong></p>
and it works perfectly for everything except the href tag. I don't mind switching methodology but that's what I found for now.
If anyone could help or tell me what Im doing wrong. Thanks