ニュースレターに国と州のフィールドを表示したい。国については、このコーディングを使用しました:-
<?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; ?>
国のリストが表示されますが、選択した国に基づいて州のドロップダウンも表示したいと思います。州が定義されていない場合は、デフォルトのマジェント機能のようなテキストボックスが表示されます。私はこのコードを試します:-
<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>
しかし、それはエラーを示しています。どんな助けでも大歓迎です。