由于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 <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>"
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>