简体   繁体   中英

Script work only in RWD theme and don't work on default theme

I have a problem, I am using default theme on my magento site, and use this script. It works only in RWD theme. I try to find some information about it and don't find anything.Please help if you know something to help me to work this script in default theme.

<div class="block block-subscribe">
<div class="block-title">
    <strong><span><?php echo $this->__('Newsletter') ?></span></strong>
</div>
<div id="feedback" style="display:none" class="mini-newsletter">
    Thank you for subscribing to our newsletter!
</div>
<form action="<?php echo $this->getFormActionUrl() ?>" name="newsletter-form" id="newsletter-form" method="post">
    <div class="block-content">
        <div class="form-subscribe-header">
            <label for="newsletter"><?php echo $this->__('Sign Up for Our Newsletter:') ?></label>
        </div>
        <div class="input-box">
            <input type="text" placeholder="Email address" name="email" id="newsletter" title="<?php echo $this->__('Subscribe to Our Newsletter') ?>" class="required-entry input-subscribe" style="width:178px;" />
            <div class="error-news-msg" id="error-news-msg" style="display:none;">Please enter a valid email address.</div>
        </div>
        <div class="actions">
            <button type="button" title="<?php echo $this->__('Subscribe') ?>" onclick="myfunc();" class="button">
                <span><span>Subscribe</span></span>
            </button>
        </div>
    </div>
</form>

<script type="text/javascript">
    function myfunc()
    {
        var newsletterSubscriberFormDetail = new VarienForm('newsletter-form');
        var form_email = $('newsletter').getValue();
        var params_form = $('newsletter-validate-detail');
        //alert(params_form);
        if(echeck(form_email))
        {
            //alert(form_email);
            //alert(Form.serialize($('newsletter-validate-detail')));
            new Ajax.Updater({ success: 'newsletter-form' }, '<?php echo $this->getUrl('newsletter/subscriber/new') ?>', {
                asynchronous:true, evalScripts:false,
                parameters: { email: form_email },
                onComplete:function(request, json){Element.hide('newsletter-form');Element.show('feedback');},
                onLoading:function(request, json){Element.hide('news-loader');}

            });   
        }
        else
        {
            //alert(form_email);
            return false;
        }    
    }   

    function echeck(str) {    
        var at="@";
        var dot=".";
        var lat=str.indexOf(at);
        var lstr=str.length;
        var ldot=str.indexOf(dot);
        if (str.indexOf(at)==-1){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }

        if (str.indexOf(at,(lat+1))!=-1){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }

        if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }

        if (str.indexOf(dot,(lat+2))==-1){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }

        if (str.indexOf(" ")!=-1){
            //alert("Invalid E-mail ID")
            goProcedural();
            return false
        }    
        return true
    }

    function goProcedural()
    {
        Element.show('error-news-msg');
        Element.hide.delay(5, 'error-news-msg');
    }

</script>

please do change theme package folder path in admin configuration from rwd to your custom folder name. You can do this by setting the package name and theme folder name from admin panel > System > Configuration > Design

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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