<?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 Target the URL using right syntax to communicate between HubL and Javascript in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/884909#M36868</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would love to be able to change the URL in the page editor where I have a dedicated URL field for that&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;nbsp;response_redirect_url="{{ module.form_field.redirect_url }}"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, I am using a hard coded URL which is not very convenient for the marketers when they want to make the changes!&lt;BR /&gt;&lt;BR /&gt;This is the code that I am using to do a redirect to page when I submit a form :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div class="form-box form-box-{{ module.background_color }} shadow-box align-{{ module.align }}"&amp;gt;
  &amp;lt;div class="wrap-course-info"&amp;gt;
    &amp;lt;{{ module.title_tag }}&amp;gt;{{ module.title }}&amp;lt;/{{ module.title_tag }}&amp;gt;
    {% if module.description %} &amp;lt;p class="title-description2"&amp;gt;{{ module.description }}&amp;lt;/p&amp;gt;{% endif %}
    {% if module.text %} {{ module.text }}{% endif %}


    {% form
	form_to_use="{{ module.form_field.form_id }}"
	response_response_type="{{ module.form_field.response_type }}"
	response_message="{{ module.form_field.message }}"
	response_redirect_id="{{ module.form_field.redirect_id }}"
	response_redirect_url="{{ module.form_field.redirect_url }}"
	gotowebinar_webinar_key="{{ module.form_field.gotowebinar_webinar_key }}"

  %}


  &amp;lt;script&amp;gt;
  
    window.addEventListener('message', event =&amp;gt; {
    if (event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmitted') {
      
     window.location.href = "mywebsite.com" + `?email=${event.data.data.submissionValues.email}`;
     console.log("email", event.data.data.submissionValues.email, event.data.data);
     console.log("Dynamic URL:", event.data.data.submissionValues.redirectUrl);
      }
       
    });
           
  &amp;lt;/script&amp;gt;

  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This Console printed &amp;gt; Undefined&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; console.log("Dynamic URL:", event.data.data.submissionValues.redirectUrl);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the ones I tested to substitute the URL "mywebsite.com":&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AzharBondi_0-1701089621741.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/103970i8613ED6877A8916F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AzharBondi_0-1701089621741.png" alt="AzharBondi_0-1701089621741.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AzharBondi_2-1701089782065.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/103973iF8A50A626C7E62FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AzharBondi_2-1701089782065.png" alt="AzharBondi_2-1701089782065.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AzharBondi_1-1701089708519.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/103971i678BCF37F095C405/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AzharBondi_1-1701089708519.png" alt="AzharBondi_1-1701089708519.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas how can I target : response_redirect_url="{{ module.form_field.redirect_url }}" within the JavaScript snippet?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;Azhar Bondi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2023 13:01:31 GMT</pubDate>
    <dc:creator>AzharBondi</dc:creator>
    <dc:date>2023-11-27T13:01:31Z</dc:date>
    <item>
      <title>Target the URL using right syntax to communicate between HubL and Javascript</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/884909#M36868</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would love to be able to change the URL in the page editor where I have a dedicated URL field for that&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;nbsp;response_redirect_url="{{ module.form_field.redirect_url }}"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now, I am using a hard coded URL which is not very convenient for the marketers when they want to make the changes!&lt;BR /&gt;&lt;BR /&gt;This is the code that I am using to do a redirect to page when I submit a form :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div class="form-box form-box-{{ module.background_color }} shadow-box align-{{ module.align }}"&amp;gt;
  &amp;lt;div class="wrap-course-info"&amp;gt;
    &amp;lt;{{ module.title_tag }}&amp;gt;{{ module.title }}&amp;lt;/{{ module.title_tag }}&amp;gt;
    {% if module.description %} &amp;lt;p class="title-description2"&amp;gt;{{ module.description }}&amp;lt;/p&amp;gt;{% endif %}
    {% if module.text %} {{ module.text }}{% endif %}


    {% form
	form_to_use="{{ module.form_field.form_id }}"
	response_response_type="{{ module.form_field.response_type }}"
	response_message="{{ module.form_field.message }}"
	response_redirect_id="{{ module.form_field.redirect_id }}"
	response_redirect_url="{{ module.form_field.redirect_url }}"
	gotowebinar_webinar_key="{{ module.form_field.gotowebinar_webinar_key }}"

  %}


  &amp;lt;script&amp;gt;
  
    window.addEventListener('message', event =&amp;gt; {
    if (event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormSubmitted') {
      
     window.location.href = "mywebsite.com" + `?email=${event.data.data.submissionValues.email}`;
     console.log("email", event.data.data.submissionValues.email, event.data.data);
     console.log("Dynamic URL:", event.data.data.submissionValues.redirectUrl);
      }
       
    });
           
  &amp;lt;/script&amp;gt;

  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This Console printed &amp;gt; Undefined&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; console.log("Dynamic URL:", event.data.data.submissionValues.redirectUrl);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the ones I tested to substitute the URL "mywebsite.com":&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AzharBondi_0-1701089621741.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/103970i8613ED6877A8916F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AzharBondi_0-1701089621741.png" alt="AzharBondi_0-1701089621741.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AzharBondi_2-1701089782065.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/103973iF8A50A626C7E62FF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AzharBondi_2-1701089782065.png" alt="AzharBondi_2-1701089782065.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3/&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AzharBondi_1-1701089708519.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/103971i678BCF37F095C405/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AzharBondi_1-1701089708519.png" alt="AzharBondi_1-1701089708519.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas how can I target : response_redirect_url="{{ module.form_field.redirect_url }}" within the JavaScript snippet?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;Azhar Bondi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2023 13:01:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/884909#M36868</guid>
      <dc:creator>AzharBondi</dc:creator>
      <dc:date>2023-11-27T13:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Target the URL using right syntax to communicate between HubL and Javascript</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/886039#M36896</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/597903"&gt;@AzharBondi&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Did you get this resolved? I wonder if the issue you shared is related to HubL running server-side and JS being client-side. And the JS can't access your HubL variable the way you are expecting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd love to hear your thoughts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Jaycee&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 20:31:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/886039#M36896</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-11-28T20:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Target the URL using right syntax to communicate between HubL and Javascript</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/887221#M36922</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I still couldn't figure out how to solve this and I assume it is related to what you mentioned above !&lt;BR /&gt;If I solve it, I will share the solution here !&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 14:39:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Target-the-URL-using-right-syntax-to-communicate-between-HubL/m-p/887221#M36922</guid>
      <dc:creator>AzharBondi</dc:creator>
      <dc:date>2023-11-30T14:39:50Z</dc:date>
    </item>
  </channel>
</rss>

