Can't get hidden marketo field to show when changing <select> option via javascript
Hello,
I'm attempting to change a <select> option based on the page URL. I have different hidden fields set to display based on the option chosen.
So for example... if url is /yyy/ it will change the select field option to the "yyy" one.
<select id="form-select">
<option value="yyy">yyy option </option>
<option value="zzz">zzz option </option>
</select>
My issue is that while the select option properly changes using (document).ready + MktoForms2.whenReady, the hidden field associated with that select option does not display. It only works properly when I manually select it using my mouse.
@sanfordwhiteman sorry to tag you, do you have a proper solution to this approach?
I'm using a combo of jquery and the 2.0 api to try and accomplish this.
With targeting form ID:
$(document).ready(() => {
MktoForms2.whenReady((mktoForm) => {
var formId = form.getId();
if (formid == xxxx) {
$('#form-select').val('yyy');
}
});
});
No form ID targeting:
$(document).ready(() => {
MktoForms2.whenReady((mktoForm) => {
$('#form-select').val('yyy');
});
});
Any info/help is very much appreciated. Kind regards,
Bruno