Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 359

Javascript variable not being passed to ampscript when using Save button. The form should not be submitted

$
0
0
<form><input id="firstName" name="firstName" type="text" placeholder="First Name"><input id="lastName" name="lastName" type="text" placeholder="Last Name"><input id="email" name="email" type="text" placeholder="Email"><button id="button" class="button" onclick="returnData()">Next</button></form><script runat="server">  function returnData() {    var email = document.getElementById("email").value;   }     Platform.Variable.SetValue(@email, "email");</script>%%=v(@email)=%%

I am trying to pass a javascript variable to ampscript but it's not working. I'm not submitting the form but adding a saved button to capture the email. Below is the code I used. Where am I going wrong? My form is in the comment section.

<form><input id="firstName" name="firstName" type="text" placeholder="First Name"><input id="lastName" name="lastName" type="text" placeholder="Last Name"><input id="email" name="email" type="text" placeholder="Email"><button id="button" class="button" onclick="returnData()">Next</button></form>

Viewing all articles
Browse latest Browse all 359

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>