简体   繁体   English

一个列表的 Mailchimp 多个订阅表格

[英]Mailchimp Multiple Subscription Forms for one list

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).我在指向一个列表的 html 页面中嵌入了三个不同的自定义 mailchimp 表单(每个表单都有两个相似的字段和一个不同的隐藏字段)。

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.响应消息(成功或错误)仅在第一个表单的 div #mce-response中显示在同一页面中。 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:我不是 Java Script 用户,但经过一些研究,我发现这与外部脚本有关:

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

Is there any solution through mailchimp settings or we have to use JavaScript file?有没有通过mailchimp设置的解决方案,或者我们必须使用JavaScript文件?

I understood that this script is valid only for the first form.我知道这个脚本只对第一种形式有效。 Any idea how to do this?知道如何做到这一点吗? Thanks谢谢

Apparently using iframes works.显然使用 iframes 有效。

Please refer tothis 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.不要将注册表单嵌入代码页面中的代码粘贴到您的站点中,而是将其粘贴到文本文档中(使用 NotePad (PC) 或 TextEdit (Mac))并将其命名为“signup-form.html”或类似名称。 You may want to wrap the form in a div for styling and add some inline styles.您可能希望将表单包装在 div 中以进行样式设置并添加一些内联样式。 So the HTML document will look something like this:所以 HTML 文档看起来像这样:

<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.然后将这个 HTML 文档(“signup-form.html”或任何你叫它的名字)上传到你服务器上的某个地方。

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 调用 HTML,如下所示:

<iframe src="http://your-site.com/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.使用 Ajax 黑猩猩。 This will (1) prevent redirecting your subscribers away from your page and (2) allow multiple forms.这将 (1) 防止将您的订阅者从您的页面重定向,以及 (2) 允许多个表单。

https://github.com/scdoshi/jquery-ajaxchimp https://github.com/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.如果将每个mailchimp 表单包装在一个.... 中,然后在页面上运行此脚本,它将重新分配非焦点表单的所有ID,并重新绑定提交事件。 A bit hacky, but it works if you're in a bind.有点 hacky,但如果你陷入困境,它会起作用。

// 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.com/downloads.mailchimp.com/js/mc-validate.js');
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM