AnsweredAssumed Answered

Javascript for Subscription Center Unsubscribe Form

Question asked by b36c4ee87a9f6b9d2b3e32b809b045fbd04501da on May 11, 2015
Latest reply on Mar 16, 2016 by Vishal Shirguppi

Hello all,

 

I know there have been a few discussions on this topic in the forums, but I haven't been able to find a direct answer.  We recently had a web develoepr build a subscription center for us that would be mobile responsive and incorporate javascript for unchecking subscriptions when the unsubscribe box is checked and vice versa.  It wasn't until I was in testing phases that I realized that pre-fill would not work because the form was embedded into the html of the Marketo template.

 

I am now rebuilding the subscription center and pulling in the form as a drag and drop element so that we can still use the pre-fill functionality.  How do I incorporate the javascript that the develoepr built for checking and unchecking subscriptions?  I have tried to put the script in a custom html box element on the landing page and also tried to incorporate it into a new template in which the form is not embedded.  I still cannot get it to function properly.

 

Any help would be much appreciated - here is some of the javascript:

 

                            //clear unsub checkbox if any sub is checked
                            $jQ("input#blogSubscription, input#promotionsSubscription, input#productSubscription").click(function(){
                                $jQ("input#Unsubscribed").prop("checked", false);

                            });
                      
                            //clear sub checkboxes if unsub is checked
                            $jQ("input#Unsubscribed").click(function(){
                                $jQ("input#blogSubscription, input#promotionsSubscription, input#productSubscription").prop("checked", false);
                            });
                      
                            //highlight whole email field on focus
                            $jQ("input#Email").focus(function(){
                                $jQ(this).on('mouseup', function(){
                                    $jQ(this).select();
                                });
                            });
                       
                            //validate at least one input
                            form.onValidate(function(){
                                var isValid = false;
                                $jQ("input#blogSubscription, input#promotionsSubscription, input#productSubscription, input#Unsubscribed").each(function(){
                                    if($jQ(this).is(':checked')){
                                        isValid = true;

 

Thanks,
Lan K

Outcomes