APIs & Integrations

grpaiva
Member

How to listen to a change event of a select field with jQuery?

Hey there!

 

I'm trying to set a hidden field based on a select field option in a HS form. I'm inserting the form on a page via JavaScript, and adding a change listener inside 'onFormReady' property. The code below only works when I turn on "Unstyled form", but not with regular iframe form. How to make that work with regular iframe form?

 

       hbspt.forms.create({
          portalId: "XXXXXX",
          formId: formId,
          onFormReady: function($form, ctx) {
            $('select[name="venue_region"]').change(function(){
              console.log($(this).val());
            });
          },           
        });

Cheers!

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to listen to a change event of a select field with jQuery?

Hey @grpaiva ,

 

Embed code customizations aren't supported for iframe forms, since those are processed and rendered by HubSpot. In order to take advantage of the custom form embed code functions, you'll need to stick with the HTML form options.

0 Upvotes