下拉列表中的第一个选项禁用表单上的提交按钮

时间:2013-08-15 20:11:35

标签: php javascript wordpress forms mailchimp

我的网站上有一个与Mailchimp连接的表单。除了从下拉菜单中选择顶部选项(当前为“全部”)之外,这一切似乎都完美无缺。

以下是表单的代码:

    <?php if(is_front_page()) { ?>

<style>
.fixed_header.social_header #main{padding-top: 0px!important;}
.mailchimp{ width: 100%;background: url(<?php bloginfo('template_url') ?>/images/bg_mc.png) no-repeat; background-position: left top; background-size: 100% 100% ; min-height: 399px; padding: 154px 0 20px 0;}
.inner-mailchimp{margin: 0 auto; width: 805px; text-align: center;}
.mailchimp h1, .mailchimp h3{color: #fff;} 
/*#news_mc, #everything, #business_mc, #technology_mc, #dnd_mc, #smedia_mc{display: none;}*/
#mc_embed_signup{background: none!important;}
#everything_mc{ display: block;}
.form_mc{width: 400px; float: left;}
#mc_embed_signup .mc-field-group select{ padding: 7px 0!important;}
#dnd_mc, #news_mc, #business_mc, #technology_mc, #smedia_mc{display:none;}
.mc-field-group label{color: #fff;}
#mc-embedded-subscribe-form .clear{visibility: visible; overflow: visible; right: -271px;  top: -13px; background: url(<?php bloginfo('template_url');?>/images/c.png ); position: relative;}
#mc_embed_signup .button{ background-color: #005CBF!important; font-weight: normal!important;}

</style>
<script>

function fill_email(my_mail){
    var fillupemail = document.getElementById(my_mail).value;
    //alert(fillupemail);
    document.getElementById('unique_news').value = fillupemail;
    document.getElementById('unique_business').value = fillupemail;
    document.getElementById('unique_dnd').value = fillupemail;
    document.getElementById('unique_everything').value = fillupemail;
    document.getElementById('unique_smedia').value = fillupemail;
    document.getElementById('unique_technology').value = fillupemail;

}

function mailchange(id){
    var x = document.getElementById(id);

    if(x.value == 'everything'){
        document.getElementById('dnd_mc').style.display='none';
        document.getElementById('news_mc').style.display='none';
        document.getElementById('business_mc').style.display='none';
        document.getElementById('technology_mc').style.display='none';
        document.getElementById('smedia_mc').style.display='none';

        document.getElementById(x.value+'_mc').style.display='block';
    }
    if(x.value == 'news'){
        document.getElementById('everything_mc').style.display='none';
        document.getElementById('dnd_mc').style.display='none';
        document.getElementById('business_mc').style.display='none';
        document.getElementById('technology_mc').style.display='none';
        document.getElementById('smedia_mc').style.display='none';

        document.getElementById(x.value+'_mc').style.display='block';
    }
    if(x.value == 'business'){
        document.getElementById('everything_mc').style.display='none';
        document.getElementById('dnd_mc').style.display='none';
        document.getElementById('news_mc').style.display='none';
        document.getElementById('technology_mc').style.display='none';
        document.getElementById('smedia_mc').style.display='none';

        document.getElementById(x.value+'_mc').style.display='block';
    }
    if(x.value == 'technology'){
        document.getElementById('everything_mc').style.display='none';
        document.getElementById('dnd_mc').style.display='none';
        document.getElementById('news_mc').style.display='none';
        document.getElementById('business_mc').style.display='none';
        document.getElementById('smedia_mc').style.display='none';

        document.getElementById(x.value+'_mc').style.display='block';
    }
    if(x.value == 'dnd'){
        document.getElementById('everything_mc').style.display='none';
        document.getElementById('news_mc').style.display='none';
        document.getElementById('business_mc').style.display='none';
        document.getElementById('technology_mc').style.display='none';
        document.getElementById('smedia_mc').style.display='none';

        document.getElementById(x.value+'_mc').style.display='block';
    }
    if(x.value == 'smedia'){
        document.getElementById('everything_mc').style.display='none';
        document.getElementById('dnd_mc').style.display='none';
        document.getElementById('news_mc').style.display='none';
        document.getElementById('business_mc').style.display='none';
        document.getElementById('technology_mc').style.display='none';

        document.getElementById(x.value+'_mc').style.display='block';
    }

}
</script>

<div class="mailchimp">
    <div class="inner-mailchimp">
        <h1>Scientia potentia est</h1>
        <h3>Knowledge is Power</h3>
        <div class="form_mc">
            <?php include('mailchimp-everything.php'); ?>
            <?php include('mailchimp-news.php'); ?>
            <?php include('mailchimp-business.php'); ?>
            <?php include('mailchimp-technology.php'); ?>
            <?php include('mailchimp-dnd.php'); ?>
            <?php include('mailchimp-smedia.php'); ?>
        </div><!-- form -->
        <div class="form_mc">

            <div class="everything_mc display_mc" id="mc_embed_signup"><form>
            <div class="mc-field-group selectmail_mc">
                <label for="mce-EMAIL">Interest </label>
                <select onchange="mailchange(this.id)" id="selectmail_c">
                    <option value="everything">All</option>
                    <option value="news">News</option>
                    <option value="business">Business</option>
                    <option value="technology">Technology</option>
                    <option value="dnd">Design & Development</option>
                    <option value="smedia">Social Media</option>
                </select>
            </div></form>
            </div>

        </div><!-- form -->
        <small style="color: #FFFFFF; float: left; font-size: 13px; margin-bottom: 20px; text-align: center; width: 100%;">Don't worry there's no spam just intriguing posts and <u>free</u> resources.</small>
    </div>
</div>
 <?php } ?>

我已经在下拉列表中检查了每个选项的单独文件,但它们看起来都是正确的,所以我认为问题必须在此代码中。不幸的是,我无法理解它可以解释问题所在。

编辑:This is the site,它就是标题下面的表单。

任何帮助都非常感谢,谢谢!

1 个答案:

答案 0 :(得分:0)

如果你从下拉菜单中选择一个不同的选项然后回到第一个下拉选项它可以吗? (不幸的是,由于我的低代表我不能发表评论)我觉得问题可能是你的邮件更改功能没有在页面加载时调用,所以你必须实际“选择”所有选项而不是默认值。