在magento定制城市下拉列表

时间:2015-05-19 18:27:30

标签: php magento

由于magento没有提供城市下拉菜单,我尝试在我的persistent/checkout/onepage/billing.phtml页面上添加自定义代码。我添加了这个,但是城市并没有填充下拉列表,但是当我在一个单独的html页面上尝试它时,它实际上就会下降。

这是我的代码:

<div class="input-box">
    <select class="validate-select" id="billing:region_id" name=
    "billing[region_id]" style="display:none;" title=
    "<?php echo $this->__('State/Province') ?>">
        <option value="">
            <?php echo $this->__('Please select region, state or province') ?>
        </option>
    </select> 
    <script type="text/javascript">
    $('billing:region_id').setAttribute('defaultValue',  "<?php echo $this->getAddress()->getRegionId() ?>");
    </script> <input class=
    "input-text &lt;?php echo $this-&gt;helper('customer/address')-&gt;getAttributeValidationClass('region') ?&gt;"
    id="billing:region" name="billing[region]" style="display:none;" title=
    "<?php echo $this->__('State/Province') ?>" type="text" value=
    "<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>">
</div>
<div class="field">
    <label class="required" for=
    "billing:city"><em>*</em><?php echo $this->__('City') ?></label>
    <div class="input-box">
        <input class="input-box" name="name" type="text"> 
        <script type="text/javascript">
        $('select').change(function(){
        if(('billing:region_id').val()!="1")
        $('.input-box').replaceWith("<input class="input-box" type='text' name='name'>");
        else
        $('.input-box').replaceWith('<select class="input-box"><option>a<\/option><\/select>');
        }).change();
        </script>
    </div>
</div>

0 个答案:

没有答案