The issue I have is when the form is submitted. This particular select input is required. And when submitting the form, there is a validation error of “missingSelect”. And the select field resets itselt and no longer has the prefilled value selected. With an inline form error of “Please complete this required field.”
I’ve been able to set the “selected” property for an option on a select input using advice found here: https://community.hubspot.com/t5/APIs-Integrations/How-to-change-select-option-in-HubSpot-forms-via-…
This is the code I’m using the programatticaly set an option for a select input
$('select[name="primary_country"] > option[value="Tonga"]').prop("selected", true).change();
HTML looks like this:
<select id="primary_country-de3a696a-66ee-46ea-a8e9-0ebc4f65e5c3" required="" class="hs-input is-placeholder" name="primary_country">
<option disabled="" value="">Select your country</option>
<option value="Afghanistan">Afghanistan (<U+202B>افغانستان<U+202C>)</option>
<option value="Albania">Albania (Shqipëri)</option>
<option value="Algeria">Algeria (<U+202B>الجزائر<U+202C>)</option>
.
.
.
</select
Any ideas on how to fix this issue?
Thanks so much for any help you can provide,
Ryan Johnston