我有一段代码可以创建国家/地区的下拉列表
<div class="input-box">
<?php $_countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false) ?>
<?php if (count($_countries) > 0): ?>
<select name="country" id="country" onchange="print()">
<option value=""> </option>
<?php foreach($_countries as $_country): ?>
<option value="<?php echo $_country['value'] ?>">
<?php echo $_country['label'] ?>
</option>
<?php endforeach; ?>
</select>
<?php endif; ?>
</div>
我无法弄清楚如何获得用户选择的国家/地区。你能帮我吗?
答案 0 :(得分:1)
<div class="input-box">
<?php $_countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false) ?>
<?php if (count($_countries) > 0): ?>
<select name="country" id="country" onchange="showCountry(this)">
<option value=""> </option>
<option value="<?php echo $_country['value'] ?>" <?php echo $select; ?> >
<?php echo $_country['label'] ?>
</option>
<?php endforeach; ?> </select>
<?php endif; ?>
</div>
function showCountry(ele){
alert(ele.value);
}