# Target the URL using right syntax to communicate between HubL and Javascript

**URL:** <https://community.hubspot.com/t/target-the-url-using-right-syntax-to-communicate-between-hubl-and-javascript/94823>\
**Category:** CMS Development\
**Tags:** javascript, forms\
**Created:** [November 27, 2023, 1:01pm UTC](https://community.hubspot.com/t/target-the-url-using-right-syntax-to-communicate-between-hubl-and-javascript/94823 "2023-11-27T13:01:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AzharBondi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/azharbondi/32/89457_2.png) [@AzharBondi](https://community.hubspot.com/u/AzharBondi)\
**Post date:** [November 27, 2023, 1:01pm UTC](https://community.hubspot.com/t/target-the-url-using-right-syntax-to-communicate-between-hubl-and-javascript/94823/1 "2023-11-27T13:01:31Z")

</div>

Hi,

I would love to be able to change the URL in the page editor where I have a dedicated URL field for that

\> response\_redirect\_url=“{{ module.form\_field.redirect\_url }}”

Right now, I am using a hard coded URL which is not very convenient for the marketers when they want to make the changes!  
This is the code that I am using to do a redirect to page when I submit a form :

```lia-code-sample
<div class="form-box form-box-{{ module.background_color }} shadow-box align-{{ module.align }}">
 <div class="wrap-course-info">
 <{{ module.title_tag }}>{{ module.title }}</{{ module.title_tag }}>
 {% if module.description %} <p class="title-description2">{{ module.description }}</p>{% 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 }}"

 %}

 <script>

 window.addEventListener('message', event => {
 if (event.data.type === 'hsFormCallback' && 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);
 }

 });

 </script>

 </div>
</div>

```

This Console printed \> Undefined

` console.log("Dynamic URL:", event.data.data.submissionValues.redirectUrl);`

These are the ones I tested to substitute the URL “[mywebsite.com](http://mywebsite.com)”:

1/

![AzharBondi_0-1701089621741.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/5/254120a4318e49f6271d1bc4fa976f3caafb4b59.png)

2/

![AzharBondi_2-1701089782065.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/8/d827ec44117270ca281dc9bc9884dc460c34d073.png)

3/

![AzharBondi_1-1701089708519.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/6/5/65360182f40b9026832547013ff591379682b169_2_690x31.png)

any ideas how can I target : response\_redirect\_url=“{{ module.form\_field.redirect\_url }}” within the JavaScript snippet?  
Best regards,

Azhar Bondi

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [November 28, 2023, 8:31pm UTC](https://community.hubspot.com/t/target-the-url-using-right-syntax-to-communicate-between-hubl-and-javascript/94823/2 "2023-11-28T20:31:04Z")

</div>

Hey, @AzharBondi 👋 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.

I’d love to hear your thoughts.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![AzharBondi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/azharbondi/32/89457_2.png) [@AzharBondi](https://community.hubspot.com/u/AzharBondi)\
**Post date:** [November 30, 2023, 2:39pm UTC](https://community.hubspot.com/t/target-the-url-using-right-syntax-to-communicate-between-hubl-and-javascript/94823/3 "2023-11-30T14:39:50Z")

</div>

Hey [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) !

Yes, I still couldn’t figure out how to solve this and I assume it is related to what you mentioned above !  
If I solve it, I will share the solution here !  
Thank you
