如何制作javascript / mailchimp函数以在点击时提交表单数据

时间:2019-03-25 11:13:37

标签: javascript html forms mailchimp

我有一个使用Mailchimp的联系表单,它可以工作,但是我需要一个新功能,因为我的网站上有另一个表单,但是我不能使用该联系表单,因为它没有与另一个表单相同的字段。而且,由于我是javascript的新手,所以我不知道该怎么做。你能帮我吗?

我尝试重新创建联系表单的相同功能,但使用新字段,但是没有提交表单。这是我尝试过的:

JAVASCRIPT / MAILCHIMP功能

$('#mc-embedded-download-form').ajaxChimp({
     callback: mailchimpCallback,
     url: "myURL"  
});

function mailchimpCallback2(resp2) {
    if (resp2.result === 'success') {
      $.growl({ title: "Thanks!", message: "Your message has been sent 
  sucessfully. <br/>We'll be in touch soon.", duration: 7000, style: 
  "notice" });
      $('#mcee-NAME').val('');
      $('#mcee-EMAIL').val('');
      $('#mcee-CHECK').val('');

    } else if(resp.result === 'error') {
     $.growl({ title: "Oops...", message: "An error has occurred sending your message.<br/>", duration: 7000, style: "error" });
     }  
}

HTML代码

<div class="subscribe-section">         
            <form class="subscription-form mailchimp form-inline" role="form" action="" method="post" id="mc-embedded-download-form" name="mc-embedded-download-form" >
            <div id="mc_embed_signup_scroll">
                <div class="mc-field-group">
                    <div class="row">
                        <div class="col-sm-6 col-md-6">
                            <input type="text" placeholder="Type your name here" value="" aria-required="true"
                                         name="NAME" class="form-control input-box required pull-right" id="mcee-NOME">
                        </div>
                        <div class="col-sm-6 col-md-6">
                            <input type="text" placeholder="Type your email here" value="" aria-required="true"
                                         name="EMAIL" class="form-control input-box required pull-left" id="mcee-EMAIL">
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12 col-md-12">
                    <input type="checkbox" name="aceite" value="1" aria-invalid="false" id="mcee-CHECK">
                    <span> Autorizo o envio das informações preenchidas para a abase de dados do CYBER1 GROUP, para utiização no envio de mensagens específicas sobre os serviços da Cyber1 e demais temas relacionados com nossa empresa.</span>
                        </div>
                    </div>
                </div>
                <br/>
                <div id="mce-responses" class="container">
                    <div class="subscription-error" id="mce-error-response" style="display:none"></div>
                    <div class="subscription-success" id="mce-success-response" style="display:none"></div>
                </div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
                <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_d8293ae5cf8e0541d08b72ed3_d5c30164bd" tabindex="-1" value=""></div>
                <div class="container">
                    <input type="submit" value="Fazer download do E-BOOK!" name="download" id="mc-embedded-download" class="btn standard-button lang" key="sec0-botao">
                </div>
            </div>
        </form>
    </div>

0 个答案:

没有答案