0
我想在通訊中顯示國家&州領域。 對於國家,我用這個作弄: -在magento的新聞通訊中添加國家和州/省領域
<?php $_countries = Mage::getResourceModel('directory/country_collection')
->loadData()
->toOptionArray(false) ?>
<?php if (count($_countries) > 0): ?>
<label for="country"><?php echo $this->__('Country') ?></label>
<select name="country" id="newsletter">
<option value="">-- Please Select --</option>
<?php foreach($_countries as $_country): ?>
<option value="<?php echo $_country['value'] ?>">
<?php echo $_country['label'] ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>
這表明國家的名單,但我也想根據所選國家&下顯示,如果沒有定義狀態,那麼它會顯示類似默認Magento的功能文本框中狀態下降。 我試試這個代碼: -
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<script type="text/javascript">
//<![CDATA[
$('region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
//]]>
</script>
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
但它顯示錯誤。 任何幫助是高度讚賞。