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="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>

我不知道如何获得用户选择的国家。你能帮我么?

4

1 回答 1

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);
}  ​
于 2012-11-02T08:49:18.933 回答