首 页  >>  E商学院  >>  Magento探索  >>  在支付页面把单选框改为下拉菜单

在支付页面把单选框改为下拉菜单

 

在支付页面想要把原来的单选框式的样式改为下拉菜单样式,首先找到模板文件(例如:methods.phtml)把里面 <?php
    foreach ($methods as $_method):
        $_code = $_method->getCode();
        ?>

        <dt>
        <?php if (!$oneMethod): ?>
            <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if ($this->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?> class="radio" />
        <?php else: ?>
            <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
                <?php $oneMethod = $_code; ?>
            <?php endif; ?>
        <label for="p_method_<?php echo $_code ?>"><?php echo $this->getMethodTitle($_method) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
        </dt>
        <?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
            <dd>
                <?php echo $html; ?>
            </dd>
        <?php endif; ?>
    <?php endforeach; ?>(此代码是获得支付方法的id并画出单选框)

之前加上:<DIV><select class="paypalxiala"onchange="javascript:onchg($(this).value);">
        <option>--please select--</option>
        <?php
        foreach ($methods as $_method):
            $_code = $_method->getCode();
            ?>
            <option onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if ($this->getSelectedMethodCode() == $_code): ?> checked="checked"<?php endif; ?> value="<?php echo $_code ?>" title="<?php echo $this->htmlEscape($_method->getTitle()) ?>"><label for="p_method_<?php echo $_code ?>"><?php echo $this->getMethodTitle($_method) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>  </option>
        <?php endforeach; ?>
    </select>
        </DIV>(这段代码的作用是获得id后画出下拉菜单并且写出支付的方式。)

之后通过修改css将原来的单选框隐藏(找到对应的css文件即可)。


点击次数:1122  发布日期:2013-04-13  【打印此页】  【关闭