为MailChimp动态设置动作WordPress

我正在使用MailChimp从订阅者的新闻收集数据。 MailChimp使用受众群体作为分组机制,我想根据用户从下拉列表中选择的值自动将用户分配给受众群体。

我无法提交完整的代码,这对问题没有太大影响。基本上,我有一个带有一些输入字段和一个下拉列表的表单。从下拉菜单中选择一个选项时,需要将表单操作设置为该选项的值。这是与“受众”相关的值,该部分已经过测试。

在底部的Javascript中,我尝试了两种设置form属性的方法,都为该属性分配了正确的值,但是似乎没有一种起作用。两者均已在可供其使用的备用系统中进行了测试。另外,我选择了正确的表格,也进行了测试。这就是为什么我被认为这可能与阻止我的代码的系统设置有关。

WordPress中是否存在某种设置阻止我设置表单操作?

<form onsubmit='location.href="http://wordpress.localhost.be/nl/home-page/"' action="" method="post" autocomplete="on" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
<label>Je ontvangt emails met relevante informatie. Verder ontvang je een sample uit onze library.</label><br><br>         
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
    <label for="mce-EMAIL">Email Adres  <span class="asterisk">*</span>
</label>
    <input autocomplete="email" type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
    <label for="mce-FNAME">Voornaam <span class="asterisk">*</span></label>
    <input autocomplete="given-name" type="text" value="" name="FNAME" class="required" id="mce-FNAME">
</div>
<div class="mc-field-group">
    <label for="mce-LNAME">Achternaam <span class="asterisk">*</span></label>
    <input autocomplete="family-name" type="text" value="" name="LNAME" class="required" id="mce-LNAME">
</div>
<div class="mc-field-group">
    <label for="mce-MMERGE5">Bedrijf <span class="asterisk">*</span></label>
    <input autocomplete="organization" type="text" value="" name="MMERGE5" class="required" id="mce-MMERGE5">
</div>
<div class="mc-field-group">
    <label>Locatie <span class="asterisk">*</span> </label>
    <select id="location_id" class="require">
        <option disabled selected value> -- select an option -- </option>
        <option value="xxxxxx">Vlaams-Brabant</option>
        <option value="xxxxxx">Antwerpen</option>
        <option value="xxxxxx">Limburg</option>
        <option value="xxxxxx">Oost-Vlaanderen</option>
        <option value="xxxxxx">West-Vlaanderen</option>
    </select>
</div>

<script>

    document.getElementById("location_id").onchange = function(){

        var form_mailchimp = document.getElementById("mc-embedded-subscribe-form");

        var id_location = document.getElementById("location_id").value;

        // First method tried : FAILS
        form_mailchimp.setattribute('action',"https://vca-online.us20.list-manage.com/subscribe/post?u=5c5525811fe8c82d3269992c2&amp;id=" + id_location); 

        console.log(form_mailchimp.getattribute('action'));    


        // Second method tried : FAILS 
        form_mailchimp.action = "https://vca-online.us20.list-manage.com/subscribe/post?u=5c5525811fe8c82d3269992c2&amp;id=" + id_location; 

        console.log(form_mailchimp.action);

    }

</script>
wanderer0 回答:为MailChimp动态设置动作WordPress

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2971835.html

大家都在问