CMS Development

mansigovani
Contributor

Adding dynamic content to pages

I have two HTML files 

<!doctype html>
<html>
<head>
<script type="application/javascript" src="js.js">
</script>

<meta charset="utf-8">
<title>Links</title>
</head>

<body>

<a href="download.html?id=apple" id="apple" name="apple">Apple</a><br>
<a href="download.html?id=banana" id="banana" name="banana">Banana</a><br>
<a href="download.html?id=carrot" id="carrot" name="carrot">Carrot</a>
</body>
</html>

-------------------------------------------------------------------------------------------------------------------------

<!DOCTYPE html>
<html>
<head>


<style>
#demo{
display: none;
background-color: yellow;
}
#demo1{
display: none;
background-color: yellow;
}

#demo2{
display: none;
background-color: yellow;
}

</style>
<script type="application/javascript">

var text1 = getQueryVariable("id");

function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);

}

function submitform() {

document.getElementById("form1").action = "final.html?myparam="+text1;
return true;
}
</script>

</head>
<body>

<h2>My First Web Page</h2>
<p>My First Paragraph.</p>


<form method="post" id="form1">
First name: <input type="text" name="fname"><br/><br/>
Last name: <input type="text" name="lname"><br/><br/>
<input type="submit" value="Submit" onclick="submitform();">
</form>
<p id="demo">This is apple section</p>
<p id="demo1">This is banana section</p>
<p id="demo2">This is carrot section</p>
<script type="application/javascript">

var text = getQueryVariable("id");

if(text=='apple')
{
document.getElementById("demo").style.display = "inline";
}

else if (text=='banana'){
document.getElementById("demo1").style.display = "inline";
}

else if (text=='carrot'){
document.getElementById("demo2").style.display = "inline";
}
</script>


</body>
</html>

---------------------------------------------------------------------------------

How can I implement this on Hubspot as Hubspot doesn't allow inline Script?

0 Upvotes
2 Replies 2
vinebhat24
Participant

Adding dynamic content to pages

Hello @mansigovani 

 

If you are creating a custom module then you can put your js code in "JS" tab. or you can refer other way as well. 

 

FYI- https://knowledge.hubspot.com/articles/kcs_article/cos-general/add-a-javascript-file-to-hubspot

 

Hope this will help.

0 Upvotes
mansigovani
Contributor

Adding dynamic content to pages

I tried that too. It doesn't call the script in the body tag as I want.

0 Upvotes