I was embedding a hubspot form to my wordpress website and I need to run a piece of script when the form is loaded. This is the requirement, but I ran into an error and it showed like the following in the console.
Hubspot Form: There was an error when running your onFormReady function
My hubspot code is:
<script>
hbspt.forms.create({
region: "xxxxx",
portalId: "xxxxxxx",
formId: "xxxxxxxxxxxxxxxxx",
onFormSubmit: function($form) {
console.log("form is submitted already");
//some other stuff as well
jQuery('.hubspot_form_outer_class').hide();
},
onFormReady: function($form) {
console.log("success");
$("div.input > select").attr("disabled", "disabled");
}
});
</script>
Here onFormSubmit
function works fine(no problem with the jQuery script in it as well), but the function onFormReady
doesnot work. I just need to make this function work. What is the issue here? Anyone has an idea? Any help/information is much appreciated.
Thanks.
Update: Console output for jQuery("div.input > select");
I think the issue is with this line of code
$("div.input > select").attr("disabled", "disabled");
Try changing that to
jQuery("div.input > select").attr("disabled", "disabled");
Also make sure you include jQuery on the page where this script is running.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.