May 25, 2018 4:36 PM
Hi there,
Just wondering why hubspot has input ids for some inputs in hubspot fields but not others. These 2 fields are from the same form one text and one hidden. I'm using the tag manger to put data in the fields, and not having input IDs makes it really difficult.
Has ID
<input id="firstname-5251181d-c7a7-42b2-83dc-cf485f4c7307_6784" class="hs-input invalid error" name="firstname" required="" value="" placeholder="" autocomplete="given-name" data-reactid=".hbspt-forms-0.0:$0.1:$firstname.$firstname.0" type="text">
No ID
<input name="z_test_steve_temp" class="hs-input" value="not-ie" data-reactid=".hbspt-forms-0.0:$5.1:$z_test_steve_temp.$z_test_steve_temp.0" type="hidden">
Solved! Go to Solution.
Jun 4, 2018 6:56 PM
Hi @Derek_Gervais,
Thanks for the clarification.
Here is a bit of code if anyone ends up here and is trying to fill in a hubspot form input that's a hidden field.
This would put the word 'test' in a field called 'your_field_name_here'.
<script>
document.getElementsByName('your_field_name_here')[0].value = 'test';
</script>
Jun 4, 2018 6:56 PM
Hi @Derek_Gervais,
Thanks for the clarification.
Here is a bit of code if anyone ends up here and is trying to fill in a hubspot form input that's a hidden field.
This would put the word 'test' in a field called 'your_field_name_here'.
<script>
document.getElementsByName('your_field_name_here')[0].value = 'test';
</script>
Jun 4, 2018 4:46 PM
Hi @steve,
Thanks for including that example. As it turns out, we don't include an id for hidden form fields; ids are only included for visible form fields. The ids are intended for use internally by the form embed code, and aren't needed for internal form fields. I'd recommend not depending on the id attribute, and instead using the name attributes. It may seem less ideal, but the name attribute is always going to be set to the internal property name, so it's a more general and consistent way to target the fields.
May 31, 2018 10:33 AM
Hi @steve,
I'm actually not entirely sure what the expected behavior here is; can you post a link to a page that has a form like this on it? I'd like to investigate the form in question and do some testing so that I can better understand what's going on.
May 31, 2018 12:18 PM
Hi Derek,
Here is the page https://www.pfleet.com/landing/cfn
A simple example using the id with javascript
https://www.w3schools.com/tags/att_id.asp
You can use "name", but its not ideal, but just thought it was strange that some inputs have an id and some don't.
Hope that helps