APIs & Integrations

bburak
Participante

Dynamic Default Values

resolver

Hi there,

 

When  I use Wufoo Forms, it's really easy to modify default values

 

Example:

    <script type="text/javascript">var asdasdmj;(function(d, t) {
        var s = d.createElement(t), options = {
        'userName':'myusername',
        'formHash':'zx300',
        'host':'wufoo.com',
        
        'defaultValues':'field34=<?php the_title(); ?>',
        
        };
    </script>



I could not find a solution for Hubspot,
I wish something like this: 

 

<script>
  hbspt.forms.create({
            portalId: "XXXX",
            formId: "XXXX",
            defaultValues: { myfield33 : <?php the_title(); ?>  }
});
</script>

 

or I wish

 

[hubspot type=form portal=111111 id=XXXX my-field-33="mytext"]

 

I have tried this: 

https://developers.hubspot.com/manipulating-forms-with-jquery

https://knowledge.hubspot.com/forms/can-i-auto-populate-form-fields-through-a-query-string

 

Could not find a solution.

 

I don't have an access my client's account. They're just giving shortcode or embeded JS code. Is there anything I can do?

0 Me gusta
1 Soluciones aceptada
WendyGoh
Solución
HubSpot Employee
HubSpot Employee

Dynamic Default Values

resolver

Hey @bburak,

 

By modifying the default values do you mean that you'd like to set a form value on the form field when the form loads? 

 

If so, you can do something like this:

 

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
 <script>
   hbspt.forms.create({
     portalId: 'portalId',
     formId: 'formId',
     onFormReady: function($form) {
           $form.find('input[name="stringtest"]').val("kitkat2").change();
     }
   });
 </script>
        {{ standard_footer_includes }}
    </body>
</html>

Ver la solución en mensaje original publicado

2 Respuestas 2
WendyGoh
Solución
HubSpot Employee
HubSpot Employee

Dynamic Default Values

resolver

Hey @bburak,

 

By modifying the default values do you mean that you'd like to set a form value on the form field when the form loads? 

 

If so, you can do something like this:

 

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
 <script>
   hbspt.forms.create({
     portalId: 'portalId',
     formId: 'formId',
     onFormReady: function($form) {
           $form.find('input[name="stringtest"]').val("kitkat2").change();
     }
   });
 </script>
        {{ standard_footer_includes }}
    </body>
</html>
bburak
Participante

Dynamic Default Values

resolver

Thank you. 
That's the what I want.

0 Me gusta