We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Jan 15, 2022 7:36 AM
This is what I've got so far:
<script>
hbspt.forms.create({
region: "na1",
portalId: "xxxx",
formId: "xxxxx",
onFormReady: function($form) {
$form.find('input[name="message"]').val("post_title").change();
}
});
</script>
How can I insert the value to the message field dynamically with the Wordpress post title?
Jan 17, 2022 10:51 AM
Is that all of your code? If so, "post_title" is not defined anywhere. Also, if you put the title of the page/post into your "message" that an end-user can edit and remove, what is the point? If you are trying to grab a value from the page I would recommend storing it as a hidden value on the form so that it cannot be overwritten by the user. If you just want the basic title from the HTML you could reference the "document.title" from the DOM and eliminate defining your "post_title" field altogether, but it depends on your application or if there's anything else you are trying to do with your setup.
Jan 17, 2022 7:28 AM
Hi @garywhocares ,
Thank you for reaching out to us!
I would like to tag in some of our experts into this @webdew, @DavidDennison , and @Ben_M
Best,