CMS Development

AirswiftRob
Colaborador

Looking for a way to dynamically change the Label Text on a HubSpot Form

resolver

Hi,

 

We are using the API from another system to create HubDB records and dynamic pages. We are then using one form (a job application form) on all dynamic pages to track registrations.

 

On the form, we would like to change the question text for certain HubDB records if a custom screening question has been added in the other system.

For example

 

HubDB RecordOther System IDCustom Screening Question
0010067Do you like Apples?
002071Do you like Oranges
003087 

 

In records 001 & 002, I want the custom screening property label to display a question relating to apples or oranges respectively. For example 003. I do not want the question to appear at all because the field is blank.

Is this possible? 

0 Me gusta
1 Soluciones aceptada
Teun
Solución
Experto reconocido | Partner nivel Diamond
Experto reconocido | Partner nivel Diamond

Looking for a way to dynamically change the Label Text on a HubSpot Form

resolver

Hi @AirswiftRob ,

 

Yes, this is possible. I would create custom inputs with HubL  You can use HubL combined with if else statements to display a certain question. If you display your HubSpot form below those custom inputs you can use some JavaScript to add an event listener to the custom inputs and update a hidden field in the HubSpot form.

 

const customInput = document.getElementById('custom-input') 
const hiddenInput = document.querySelector('input[name="hidden_input"]');

customInput.addEventListener('change', e => {
  hiddenInput.value = customInput.value;
  hiddenInput.dispatchEvent(new Event('input', { bubbles: true }));
})

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Ver la solución en mensaje original publicado

2 Respuestas 2
AirswiftRob
Colaborador

Looking for a way to dynamically change the Label Text on a HubSpot Form

resolver

Thank you @Teun I will try this out and report back

 

0 Me gusta
Teun
Solución
Experto reconocido | Partner nivel Diamond
Experto reconocido | Partner nivel Diamond

Looking for a way to dynamically change the Label Text on a HubSpot Form

resolver

Hi @AirswiftRob ,

 

Yes, this is possible. I would create custom inputs with HubL  You can use HubL combined with if else statements to display a certain question. If you display your HubSpot form below those custom inputs you can use some JavaScript to add an event listener to the custom inputs and update a hidden field in the HubSpot form.

 

const customInput = document.getElementById('custom-input') 
const hiddenInput = document.querySelector('input[name="hidden_input"]');

customInput.addEventListener('change', e => {
  hiddenInput.value = customInput.value;
  hiddenInput.dispatchEvent(new Event('input', { bubbles: true }));
})

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.