2

I'm getting the var @CodeP = RequestParameter("j") from an URL. I want to put getting value in a Javascript value.

I tried in JS var Codep =%%=v(@CodeP)=%%; and var Codep = Variable.GetValue("@CodeP");both don't work

1 Answer 1

4

This isn't valid AMPScript:

var @CodeP = RequestParameter("j")

You have to do a @var by itself and then do a @set. You can't do them both in the same @set.

Once that's resolved, there are examples on this page:

Using Server-Side JavaScript with AMPscript

It'd be something like this using your variables:

%%[

var @CodeP
set @CodeP = RequestParameter("j")

]%%

<script runat="server">

  Platform.Load("Core","1");
  var CodeP = Variable.GetValue("@CodeP");
  Write("<br>CodeP: " + CodeP);

</script>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .