<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Getting field value on form submit in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/333390#M16248</link>
    <description>&lt;P&gt;I keep stucked at the same place, could someone help me, please?&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2020 13:34:11 GMT</pubDate>
    <dc:creator>gabrielnoal</dc:creator>
    <dc:date>2020-04-22T13:34:11Z</dc:date>
    <item>
      <title>Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/326508#M15740</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to do a dynamic redirect on base one of my form fields.&lt;BR /&gt;&lt;BR /&gt;I already look for a lot of ways of do that and I find out it would be posible if I add a event listener when form submit to get my field value and redirect my user to one page or another.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I find this link (&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Getting-form-field-on-form-submit/m-p/316974" target="_blank"&gt;https://community.hubspot.com/t5/APIs-Integrations/Getting-form-field-on-form-submit/m-p/316974&lt;/A&gt; and many others that people sugest to use:&lt;/P&gt;&lt;PRE&gt;&amp;lt;script&amp;gt;
	hbspt.forms.create({
		portalId: "my_portal_id",
		formId: "my_form_id",
		onFormSubmit: function($form){
			if($('input[value="my_field_name"]').val() === 'No'){
				callStripe();
			}
		}
	});
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;But it look's like this is for add embeded code to my web site and this is not what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tried to code something like that in the form module.js and it doesn't work.&lt;/P&gt;&lt;PRE&gt;const logSubmit = (event) =&amp;gt; {
  console.log(event)
  event.preventDefault();
}

window.addEventListener('submit', logSubmit);&lt;/PRE&gt;&lt;P&gt;It look likes this runs before the form is rendered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need something that I can add at my module.html or module.js that get the form values and redirect the user to the correct page after submits.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 18:54:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/326508#M15740</guid>
      <dc:creator>gabrielnoal</dc:creator>
      <dc:date>2020-03-18T18:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327056#M15771</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/124447"&gt;@gabrielnoal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for sharing this information. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'll tag a few experts that could share their thoughts with you. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/73772"&gt;@Kevin-C&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/67091"&gt;@prosa&lt;/a&gt;&amp;nbsp;could you please share your expertise with&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/124447"&gt;@gabrielnoal&lt;/a&gt;&amp;nbsp;?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sharon&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 10:55:27 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327056#M15771</guid>
      <dc:creator>sharonlicari</dc:creator>
      <dc:date>2020-03-23T10:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327174#M15785</link>
      <description>&lt;P&gt;hi there can you share the code you are trying to run? I've used the provided example and I was able to create a redirection after form submission. But make sure in your form configuration you have only a message and not a redirect. I would recommend showing a message and adding a spinner with a timeout to trigger the redirection.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Mar 2020 20:51:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327174#M15785</guid>
      <dc:creator>prosa</dc:creator>
      <dc:date>2020-03-23T20:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327606#M15807</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/67091"&gt;@prosa&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;I already tried a lot of ways and any of those worked for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp; used to work with ReactJs and I tried to add a event listener on form submit and add a log to see if it works, but it never logs. Also I tried to get the element by name, id, tag but all of those returns a empty array. It looks like the code runs before the form is rendered.&lt;BR /&gt;&lt;BR /&gt;This is my last try.&lt;/P&gt;&lt;P&gt;My module.html&lt;/P&gt;&lt;PRE&gt;{% if module.title is truthy %}
	{% set no_title = False %}
{% else %} 
	{% set no_title = True %}
{% endif %}
 
{% if module.form.form_id %}
	{% form
    form_key='{{ name }}',
    form_to_use='{{ module.form.form_id }}',
    title='{{ module.title }}',
    no_title='{{ no_title }}',
    follow_up_type_simple='{{ module.follow_up_type_simple }}',
    simple_email_for_live_id='{{ module.simple_email_for_live_id }}',
    follow_up_type_automation='{{ module.follow_up_type_automation }}',
    form_follow_ups_workflow_id='{{ module.form_follow_ups_workflow_id }}',
    response_response_type='{{ module.form.response_type }}',
    response_redirect_id='{{ module.form.redirect_id }}',
    response_redirect_url='{{ module.form.redirect_url }}',
    response_message='{{ module.form.message }}',
    notifications_are_overridden='{{ module.notifications_are_overridden }}',
    notifications_override_email_addresses='{{ module.notifications_override_email_addresses }}'
    gotowebinar_webinar_key='{{ module.form.gotowebinar_webinar_key }}'
    sfdc_campaign='{{ module.sfdc_campaign }}'
	%}
{% else %}
	{% form
    title='{{ module.title }}',
    no_title='{{ no_title }}',
  %}
{% endif %}&lt;/PRE&gt;&lt;P&gt;My mudule.js&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;const logSubmit = (event) =&amp;gt; {
  console.log(event)
  console.log("REDIRECT")
}

window.addEventListener('submit', logSubmit)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 15:55:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327606#M15807</guid>
      <dc:creator>gabrielnoal</dc:creator>
      <dc:date>2020-03-25T15:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327669#M15808</link>
      <description>&lt;P&gt;Try adding a listener for 'message' and check if it is the HubSpot onFormSubmit event:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;window.addEventListener('message', function (event) {
  if (event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmit') {
    console.log('onFormSubmit');
  }
});&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Mar 2020 19:40:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/327669#M15808</guid>
      <dc:creator>BenSBM</dc:creator>
      <dc:date>2020-03-25T19:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/328881#M15895</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/4991"&gt;@BenSBM&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Thank you for your answer and sorry for the delay to answer.&lt;BR /&gt;&lt;BR /&gt;But how can I check the event using Hubspot Landing Page?&lt;BR /&gt;Because I could check the event of&amp;nbsp;&lt;SPAN&gt;onFormSubmit&lt;/SPAN&gt; &amp;nbsp;if i took the embeded code and paste on my website but i'm using hubspot landing pages.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Apr 2020 15:31:05 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/328881#M15895</guid>
      <dc:creator>gabrielnoal</dc:creator>
      <dc:date>2020-04-03T15:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/333390#M16248</link>
      <description>&lt;P&gt;I keep stucked at the same place, could someone help me, please?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 13:34:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/333390#M16248</guid>
      <dc:creator>gabrielnoal</dc:creator>
      <dc:date>2020-04-22T13:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Getting field value on form submit</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/333414#M16252</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/124447"&gt;@gabrielnoal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That javascript snippet should work on any site, whether it is a HubSpot website or landing page, or on a third party service. It adds a listener for when a HubSpot form is submitted and is independent of being on a landing page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I set up a quick test in my portal, and added a form module and made sure it was set to "Display an inline thank you message". I then created a test page in HubSpot, and upon submit the eventListener previously posted printed a message to the console. The same worked in a custom module with a form field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;window.addEventListener('message', function (event) {
  if (event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmit') {
    /* print to the console on submit, or add in custom redirect in here */
    console.log('onFormSubmit');
  }
});&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 14:23:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Getting-field-value-on-form-submit/m-p/333414#M16252</guid>
      <dc:creator>BenSBM</dc:creator>
      <dc:date>2020-04-22T14:23:24Z</dc:date>
    </item>
  </channel>
</rss>

