@Albo Thats standard URI encoding for query parameters. HubSpot will decode query parameters automatically when prefilling it’s form fields. If you’re reading this value elsewhere you’ll need to decode it first using decodeURIComponent() -https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent
@derekcavaliero , thank you, you’re the man! I disabled redirect in my HS form but it isn’t redirecting. Here’s the code I’m using:
<!--[if lte IE 8]>
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
<![endif]-->
<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
<script>
hbspt.forms.create({
region: "na1",
portalId: "156754",
formId: "f2a90b0f-843a-4d96-9bfe-1311362f8edb",
cssClass: "",
inlineMessage: "You are being redirected to the Application...",
onFormSubmit: function($form){
var emailWeb = $form.find('input[name="email"]').val();
setTimeout( function() {
window.location.href = "https://www.sellanyannuity.com/lp/thanks?email=" + encodeURIComponent( emailWeb );
}, 500 ); // Redirects to url with query string data from form fields after 1/2 second.
}
});
</script>
I tried a few variations but couldn’t get it to work. Here’s a live test page so you can see yourself (feel free to test): Sell Any Annuity - Get Cash Now For Your Structured Settlement
Maybe the theme I’m using has code that is conflicting?
Thanks again,
Jim
@jkeough78 The issue you’re having is that HubSpts onFormReady() local callbacks require jQuery to function (I am aware this is a bit annoying).
If you open up your JS console in chrome and submit the form you’ll see the following exception being thrown:
The onFormSubmit function in hbspt.forms.create requires jQuery. It was not run.
You’d need to ensure you load jQuery - or polyfill the method HubSpot is looking for in its forms.js script to get those local callbacks to work.
There are ways to do this with the global callbacks that utilize the window.postMessage API - but it involves more custom javascript due to not having jQuery available for a better API to grab the field values easily.
Dude thank you very much! I will turn on JQuery. I think the only downside is that it slows the site down a little bit.
So I’ve found a work around for this, create a custom module in Hubspot and use the following code. I don’t know how to link the code without screen grabbing it on here. Inset this code into the custom module, then insert the module into the page you want. This will only redirect based upon the value of one field. you can replicate the ELSE IF section of the code if there are more than 3 options.
To change the code replace where I have put in Capital letters:
NAME1
NAME2
NAME3
OPTION
These 4 above are up to you to decide and are merely for referencing for the code to work so as long as they are the same above and below then that’s all that matters
WEBSITE1
WEBSITE2
WEBSITE3
These are the web addresses you want the page to re-direct to depending on selection
NAME OF DEPENDENT FIELD
Go to you form and right click on it, click inspect and find out the true name of the value you want to redirect based upon. E.g How_Much_Is_Your_Budget?
Make sure this is copied exactly how it appears in the inspector.
FIELDVALUE1
FIELDVALUE2
FIELDVALUE3
Make sure these are copied exactly how it appears in your form for the values is the field we have named above, e.g £1-£2 include the spaces if you have any in the field so it might be £1 - £2
Obviously make sure you update your portal id and form id also at the top where the XXXXX are

