最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Mailchimp Multiple Subscription Forms for one list - Stack Overflow

programmeradmin6浏览0评论

I embedded three different customized mailchimp forms in an html page that point to one list (each form has two similar fields and one different hidden field).

Everything works excluding one thing. The responses messages (success or error) are displayed in the same page in the div #mce-response only for the first form. In the other two the responses are loaded and displayed in another blank page. I'd like to have the reponses displayed in the same page for all the three forms. I'm not a Java Script user but after a bit of research I found that this deals with the external script:

<script type='text/javascript' src='.mailchimp/js/mc-validate.js'></script>

Is there any solution through mailchimp settings or we have to use JavaScript file?

I understood that this script is valid only for the first form. Any idea how to do this? Thanks

I embedded three different customized mailchimp forms in an html page that point to one list (each form has two similar fields and one different hidden field).

Everything works excluding one thing. The responses messages (success or error) are displayed in the same page in the div #mce-response only for the first form. In the other two the responses are loaded and displayed in another blank page. I'd like to have the reponses displayed in the same page for all the three forms. I'm not a Java Script user but after a bit of research I found that this deals with the external script:

<script type='text/javascript' src='http://s3.amazonaws./downloads.mailchimp./js/mc-validate.js'></script>

Is there any solution through mailchimp settings or we have to use JavaScript file?

I understood that this script is valid only for the first form. Any idea how to do this? Thanks

Share Improve this question edited Nov 18, 2016 at 6:00 Sunil B N 4,2251 gold badge32 silver badges53 bronze badges asked Dec 24, 2014 at 15:17 collideorscapecollideorscape 511 silver badge4 bronze badges 1
  • Did you ever find a solution for this? – Ryan Commented Dec 8, 2016 at 19:04
Add a ment  | 

3 Answers 3

Reset to default 2

Apparently using iframes works.

Please refer to this article/video.

Text from the article for explanation:

Instead of pasting the code from the Signup Form Embed Code page into your site, paste it into a text document (using NotePad (PC) or TextEdit (Mac)) and call it “signup-form.html” or something like that. You may want to wrap the form in a div for styling and add some inline styles. So the HTML document will look something like this:

<style type="text/css">
<!--
lots of CSS to make your form look pretty
//-->
</style>

<div id="sign-up">
at least 50 lines of code copied from MailChimp goes here
</div>

Then upload this HTML document (“signup-form.html” or whatever you called it) to somewhere on your server.

Then in order to embed the code on the page (as many times as you want) you call the HTML in with an iframe like this:

<iframe src="http://your-site./mailchimp-form.html" frameborder="0" width="654" height="200">
<a href="http://link-to-form-on-mailchimp-site" target="_blank">Anchor text saying "click here to sign up" or something like that for people whose browsers can't read iframes</a>
</iframe>

Use Ajax Chimp. This will (1) prevent redirecting your subscribers away from your page and (2) allow multiple forms.

https://github./scdoshi/jquery-ajaxchimp

If you wrap each mailchimp form in a ...., then run this script on the page, it will re-assign all IDs of the non-focused form, and re-bind the submit event. A bit hacky, but it works if you're in a bind.

// only execute if confirmed more than 1 mailchimp form on this page
$(document).ready(function() {

    if ( $('.mc-form-instance').length > 1 ) {

        $('.mc-field-group > .required').on('focus', function() {
            var thisField = $(this);

            // backup all mc-form ids on this page
            $('.mc-form-instance [id]').each(function() {
                var currentID = $(this).attr('id');
                if ( currentID.indexOf('-bak') == -1 ) {
                    $(this).attr('id', currentID + '-bak');
                }
            });
            // change the current form ids back to original state
            var thisForm = thisField.closest('.mc-form-instance');
            thisForm.find('[id]').each(function() {
                var currentID = $(this).attr('id');
                if ( currentID.indexOf('-bak') != -1 ) {
                    $(this).attr('id', currentID.replace('-bak', ''));
                }
            });
        });

        // re-bind
        $.getScript('//s3.amazonaws./downloads.mailchimp./js/mc-validate.js');
    }
});
发布评论

评论列表(0)

  1. 暂无评论