i have a cloud page in marketing cloud.
In cloud page, I am using ampscript and javascript both. Can i pass variables values from my ampscript to javascript directly?
I have already tried this example:
%%[
var @CodeP
set @CodeP = RequestParameter("j")
]%%
<script runat="server">
Platform.Load("Core","1");
var CodeP = Variable.GetValue("@CodeP");
Write("<br>CodeP: " + CodeP);
</script>
The problem is that this approach breaks my javascript because my javascript on cloud page starts with this:
<script type="text/javascript">
Adding runat="server" breaks the existing functionality of my javascript.
please help?