On Click不适用于JS

时间:2018-07-09 09:14:06

标签: javascript function button onclick

此处显示的代码旨在带我进入结帐流程的下一部分,但是我遇到未定义帐单的错误?我试图放置一个函数并通过onclick调用该函数,但这没有效果。

无效的代码应为代码的底部,即JS和正上方的按钮

下面是您可以看到按钮和onclick标注

的地方
<div class="buttons-set form-buttons btn-only" id="billing-buttons-container">
    <button type="button" class="btn" onclick="billing.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
    <span id="billing-please-wait" class="please-wait" style="display:none;">
        <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
    </span>
</div>
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
<?php echo $this->getBlockHtml('formkey') ?>
</form>

下面的JS无法正常工作

<script type="text/javascript">
//<![CDATA[


    var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
    var billingForm = new VarienForm('co-billing-form');

    //billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
    $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);

    var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
    if ($('onepage-guest-register-button')) {
        Event.observe($('onepage-guest-register-button'), 'click', function(event) {
            var billingRememberMe = $('co-billing-form').select('#remember-me-box');
            if (billingRememberMe.length > 0) {
                if ($('login:guest') && $('login:guest').checked) {
                    billingRememberMe[0].hide();
                } else if ($('login:register') && ($('login:register').checked || $('login:register').type == 'hidden')) {
                    billingRememberMe[0].show();
                }
            }
        });
    }
//]]>
</script>

1 个答案:

答案 0 :(得分:0)

jQuery阻止了另一个jQuery文件,因此无法按预期正常工作,但是由于删除了一个jQuery文件,它现在可以工作了:D