Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PardotGists/feda65564d01373d809f to your computer and use it in GitHub Desktop.
Save PardotGists/feda65564d01373d809f to your computer and use it in GitHub Desktop.
Using Form Field-Based Completion Actions Thank You Code Script
<script type="text/javascript">
var email = encodeURIComponent('%%email{js}%%')
switch('%%your_field_id{js}%%')
{
case 'VALUE_1': document.write('<iframe src="FORM_HANDLER_1_URL?email=' + email + '" height="1px" width="1px" />');
break;
case 'VALUE_2': document.write('<iframe src="FORM_HANDLER_2_URL?email=' + email + '" height="1px" width="1px" />');
break;
}
</script>
@hsquareweb
Copy link

The iframe is not closed properly! It should be </iframe>.

@adamerstelle
Copy link

An alternative approach:

<script type="text/javascript">
var formHandlerUrl='';
var email = encodeURIComponent('%%email{js}%%')
switch('%%your_field_id{js}%%')
{
    case 'VALUE_1': formHandlerUrl='FORM_HANDLER_1_URL'; break;
    case 'VALUE_2': formHandlerUrl='FORM_HANDLER_2_URL'; break;
}
if(formHandlerUrl !== '' )
    document.write('<iframe src="'+formHandlerUrl+'?email=' + email + '" height="1px" width="1px"> </iframe>');
</script>

@ssavulak
Copy link

ssavulak commented Feb 8, 2022

I've tried using these examples and haven't had any success. Do you know if this works for fields that have dropdown values?

Many Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment