Dynamic form thank you pages using script
Hello, I know there is a dynamic form thank you functionality in the Forms 2.0 builder where you can set the thank you page via form field values, but I was wondering how you can do it via script in the Marketo onSuccess function? The reason being, we have parameters building the thank you page URL based on the form entries and we cannot do that in the form builder.
Here is our script. Pretty much I want a dynamic "location.href" URL that varies based on what the user enters in the Postal Code field.
If it's one set of zip codes, go to a specified URL. If it's another set of zip codes, go to a different specified URL. And if the value typed in doesn't meet these 2 criteria, just go to a generic thank you page.
Any help would be appreciated! THANK YOU!
form.onSuccess(function() {
var appendFirstName = $('#FirstName').val();
var appendLastName = $('#LastName').val();
var appendEmail = $('#Email').val();
var appendPhone = $('#Phone').val();
var appendStreet = $('#Address').val();
var appendCity = $('#City').val();
var appendState = $('#State').val();
var appendZip = $('#PostalCode').val();
location.href = "OUR THANK YOU PAGE URL HERE" + '?first=' + appendFirstName + '&last=' + appendLastName + '&email=' + appendEmail + '&phone=' + appendPhone + '&street=' + appendStreet + '&city=' + appendCity + '&state=' + appendState + '&zip=' + appendZip;
return false;
});