CMS Development

AirswiftRob
Contributeur

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

Résolue

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 Votes
1 Solution acceptée
Teun
Solution
Expert reconnu | Partenaire solutions Diamond
Expert reconnu | Partenaire solutions Diamond

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

Résolue

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.


Voir la solution dans l'envoi d'origine

2 Réponses
AirswiftRob
Contributeur

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

Résolue

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

 

0 Votes
Teun
Solution
Expert reconnu | Partenaire solutions Diamond
Expert reconnu | Partenaire solutions Diamond

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

Résolue

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.