Weird behavior with pre-selected form options

Highlighted
Level 3

Weird behavior with pre-selected form options

Hi there, we are building a landing page for leads to modify their email preferences (link below)

Email Preferences

We built a form that has a series of radio buttons where leads can opt in or out of certain emails, we also have a checkbox at the bottom to completely opt out of all emails in one go. The radio buttons are set to have a default value to opt in for all email options but they only appear to be pre selected in chrome incognito window and safari. 

I was also interested in unselecting all the radio buttons if the checkbox is selected and vise versa.  So i wrote some javascript on the landing page to do this.  Again it works in the incognito window but not in a normal chrome or firefox window.  I tried writing some javascript to clear out any form caching but with no luck.  Has anyone else had issues with pre-selected values in marketo forms and have a solution they a willing to share.  Thanks in advance!

-John

$(document).ready(function() {

    $('input[type="radio"]').change(function() {

        if ($(this).is(':checked')){ //radio is now checked

            $('input[type="checkbox"]').prop('checked', false); //unchecks all checkboxes

        }

    });

    $('input[type="checkbox"]').change(function() {

        if ($(this).is(':checked')){

            $('input[type="radio"]').prop('checked', false);

        }

    });

});

3 REPLIES 3
Highlighted
Level 10 - Community Moderator

Re: Weird behavior with pre-selected form options

John, all event listeners that depend on elements in a Marketo form must be added within the MktoForms2.whenReady listener.  See Forms 2.0 » Marketo Developers.

Waiting for DOMReady doesn't suffice because the form itself is loading asynchronously.

Highlighted
Anonymous
Not applicable

Re: Weird behavior with pre-selected form options

There are a lot of things wrong with the Marketo forms, no where anywhere on the internet or in this community tells you how to fix the css inconsistencies in the forms, I'm tired of every search just directing me back to that stupid Marketo Forms 2.0 file, there HAS GOT TO BE MORE information on how these work, why can't we share more?

Highlighted
Level 10 - Community Moderator

Re: Weird behavior with pre-selected form options

Feel free to submit new Community questions (or Support cases) on any matters that concern you.

Over the past 6 months, I've shared a huge amount of pointers and demos of advanced Forms 2.0 behavior... certainly it's not true that you are only directed to the Forms 2.0 API docs (although it is vital to read and understand that page).  Have you followed the links to any of my CodePens/JSFiddles?