jQuery Not Running on Subscription Center Landing Page

Anonymous
Not applicable
A Marketo webinar on subscription centers gave us a script to automatically uncheck the individual boxes for different types of news a user could subscribe to (events, promos, product updates) if the user checked the box for "unsubscribe all." 

I updated the sample script to match our fields, tested it, and it worked! However, when I added it to my Marketo landing page (which also includes a custom HTML header, Marketo form, and custom HTML footer) inside a HTML box, it not only didn't work but the page didn't even recognize the script. When I approved the page, viewed it, and "inspected element" of the page, the script was nowhere to be found. 

Any ideas on what might be overiding my script or something extra I need to do to get the script recognized for that page? Any guidance is much appreciated!

Allison 

p.s. Here is the script I'm trying to use: 

<script type="text/javascript">
window.onload = function() {
    var unsubscribe = jQuery("#Unsubscribed"),
    subscriptions = jQuery(".mktoForm input[type='checkbox']:not(#Unsubscribed)");
console.log('running form check script');
console.log(subscriptions);
console.log(jQuery);
    unsubscribe.click(function() {
      setChecked = unsubscribe.prop('checked') ? false : true;
      subscriptions.prop("checked",setChecked);
    });
  
    subscriptions.click(function() {
      if (unsubscribe.prop("checked"))
        unsubscribe.prop("checked", false);
    });
}
</script>
Tags (1)
2 REPLIES 2
Anonymous
Not applicable
Hi Josh!

The webinar might have been kind of old. I can longer find it (and originally found it only through posts like this in the Community or on a Marketo-related blog). 

I added the script by dragging a HTML box into my landing page and pasting the script that I posted above into the box. Then I saved it, approved the page, and it isn't running. I'm wondering if some of the HTML I have in my header/footer area (which is copied from our website - to try and match branding) is interferring in some way. 

-Allison
Josh_Hill13
Level 10 - Champion Alumni
How long ago was that webinar?

How did you add the script to the page? Did you approve the page after you added the script?