Skip to main content
March 31, 2015
Question

jQuery Not Running on Subscription Center Landing Page

  • March 31, 2015
  • 2 replies
  • 1101 views
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>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Josh_Hill13
Level 10
March 31, 2015
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?
March 31, 2015
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