To completely reassociate the form with a new lead identified by email requires 2 steps.
1. Delete cookies and reload the page as to create a fresh form view.
2. Set the email address and reload the page again to get the form prefilled.
This code (in a landing page HTML widget) will set you on the right track:
<script>
MktoForms2.whenReady(function (form){
var parentDomain = location.host.split('.').slice(1).join('.');
var requestEmail, requestSubmit;
try {
requestEmail = document.location.search.match(/(?:^|\?|&)email=(.*?)(?:&|$)/i)[1];
} catch (e) {}
try {
requestSubmit = document.location.search.match(/(?:^|\?|&)submit=(.*?)(?:&|$)/i)[1];
} catch (e) {}
if ( requestEmail && requestSubmit == 'true' ) {
// set values to override email and submit form
form.setValues({ Email: requestEmail });
form.submit();
} else if ( requestEmail) {
// erase tracking cookies and reload
document.cookie="_mkto_trk=" +
";expires="+new Date(0).toGMTString() +
";domain="+parentDomain +
";path=/";
document.location.search += '&submit=true';
}
});
</script>