I am attempting to render the variable cat
which is a string within an ExpressJS statement AND a script tag.
Here is my code:
<script>
function detectChange() {
var place;
cat = document.getElementById("catType").value; // coollink
type = document.getElementById("appType").value;
if(type == "application") {
place = `<%= certain.categories.find(o => o.link == cat).placeholder %>`;
} else {
place = 'Topic description...';
};
document.getElementsByName('description')[1].innerHTML = place;
};
</script>
The specific part I have a problem with is:
place = `<%= certain.categories.find(o => o.link == cat).placeholder %>`;
I want to display cat
, which is a WebJS Variable (that for now has a value of coollink
) inside of my ExpressJS tags <%= coollink %>
however I cannot seem to display it without it erroring and telling me it has an error with compiling it.
It works just fine if I change it to say
place = `<%= certain.categories.find(o => o.link == 'coollink').placeholder %>`;
but then it's not dynamic, and it needs to be dynamic for this project.