0

我想根据下拉列表中的选择显示属性。为此,我编写了一些代码,它在本地(在 Magento 之外)运行良好,现在我想在 magento 内部解决它......我是使用 Magento CE 1.7

这是我的代码(外部magento代码)

本地代码:-

    <html>
    <head>
        <title></title>
    </head>
<body>
    <select id="xyz">
        <option value="Men">Men</option>
        <option value="Women">Women</option>
        <option value="Kids">Kids</option>
        <option value="Furniture">Furniture</option>
        <option value="Books">Books</option>
    </select>
  <div id="Men" class="group">
    Color<input id="color" name="color" type="text">
    Size<input id="size" name="size" type="text">
  </div>
  <div id="Women" class="group">
    Size<input id="size" name="size" type="text">
  </div>
  <div id="Kids" class="group">
    Color<input id="color" name="color" type="text">
  </div>
  <div id="Furniture" class="group">
    Color<input id="color" name="color" type="text">
    Size<input id="size" name="size" type="text">
    Finishing<input id="finishing" name="finishing">
  </div>
  <div id="Books" class="group">
    ISBN<input id="isbn" name="isbn" type="text">
  </div>
  </body>
    <script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script language="JavaScript" type="text/javascript">
        $(document).ready(function () {
            $('.group').hide();
        $('#Men').show();
        $('#xyz').change(function () {
            $('.group').hide();
            $('#'+$(this).val()).show();
        })
         });
    </script>
    </script>
</html>

是的现在我想在magento下拉类别中应用同样的东西我写了这个代码但是它不起作用为什么?我做错了什么吗?

Magento 代码:-

  <tr>
<td class="tdpadfirst">
   <label for="category" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Product Category') ?>:</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
</td>
<td class="tdpadsec">
    <?php $_helper = Mage::helper('catalog/category') ?>
    <?php $_categories = $_helper->getStoreCategories() ?>
    <?php $currentCategory = Mage::registry('current_category') ?>
    <?php if (count($_categories) > 0): ?>
        <select id="xyz" class="myinput-text required-entry widthinput" name="category">
        <option value="">--Select Categories--</option>
        <?php $_helper = Mage::helper('catalog/category') ?>
        <?php $_categories = $_helper->getStoreCategories() ?>
        <element onclick="<?php $currentCategory = Mage::registry('current_category') ?>">
        <?php if (count($_categories) > 0): ?>
            <?php foreach($_categories as $_category): ?>
                <option value="<?php echo $_category->getId() ?>">
                <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                <?php echo $_category->getName() ?></a>
                </option>
            <?php endforeach; ?>
        <?php endif; ?>
    <?php endif; ?>
</td>

    <div id="Mens" class="group">
   <tr>
    <td class="tdpadfirst">
        <label for="size" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Size') ?> :</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </td>
    <td class="tdpadsec">
        <input type="size" class="required-entry widthinput" name="size" id="size" value="<?php echo $size ?>"/>
        <?php echo Mage::helper('marketplacepartner')->__('For multiple values separate with , (Example: 10,20) ') ?>
    </td>
   </tr>
   <tr>
    <td class="tdpadfirst">
        <label for="seller_colour" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Color') ?> :</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </td>
    <td class="tdpadsec">
        <input type="seller_colour" class="required-entry widthinput" name="seller_colour" id="seller_colour" value="<?php echo $seller_colour ?>"/>
        <?php echo Mage::helper('marketplacepartner')->__('For multiple values separate with , (Example: White,Black) ') ?>
    </td>
   </tr>
</div>
<div id="Womens" class="group">
   <tr>
    <td class="tdpadfirst">
        <label for="size" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Size') ?> :</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </td>
    <td class="tdpadsec">
        <input type="size" class="required-entry widthinput" name="size" id="size" value="<?php echo $size ?>"/>
        <?php echo Mage::helper('marketplacepartner')->__('For multiple values separate with , (Example: 10,20) ') ?>
    </td>
   </tr>
</div>
<div id="Kids" class="group">
   <tr>
    <td class="tdpadfirst">
        <label for="seller_colour" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Color') ?> :</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </td>
    <td class="tdpadsec">
        <input type="seller_colour" class="required-entry widthinput" name="seller_colour" id="seller_colour" value="<?php echo $seller_colour ?>"/>
        <?php echo Mage::helper('marketplacepartner')->__('For multiple values separate with , (Example: White,Black) ') ?>
    </td>
   </tr>
</div>
<div id="furniture" class="group">
   <tr>
    <td class="tdpadfirst">
        <label for="seller_colour" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Color') ?> :</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </td>
    <td class="tdpadsec">
        <input type="seller_colour" class="required-entry widthinput" name="seller_colour" id="seller_colour" value="<?php echo $seller_colour ?>"/>
        <?php echo Mage::helper('marketplacepartner')->__('For multiple values separate with , (Example: White,Black) ') ?>
    </td>
   </tr>
</div>
    <script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
    $('.group').hide();
    $('#Mens').show();
    $('#category').change(function () {
    $('.group').hide();
    $('#'+$(this).val()).show();
    })
    });
</script>
</script>

我在这里使用 Magento CE 1.7

有任何想法吗 ?

4

1 回答 1

1

看来你的布局很笨拙,

<div id="Kids" class="group">
   <tr>
    <td class="tdpadfirst">
        <label for="seller_colour" class="rightgap"><?php echo Mage::helper('marketplacepartner')->__('Color') ?> :</label><span class="required starimp">&nbsp;&nbsp;&nbsp;&nbsp;</span>
    </td>
    <td class="tdpadsec">
        <input type="seller_colour" class="required-entry widthinput" name="seller_colour" id="seller_colour" value="<?php echo $seller_colour ?>"/>
        <?php echo Mage::helper('marketplacepartner')->__('For multiple values separate with , (Example: White,Black) ') ?>
    </td>
   </tr>
</div>

我不知道你怎么能把它们<tr>放在<div>标签里?,请在 div 结构中重新组织它们

<table>
<tr><td>

your category divs

</td>
</tr>
</table>
于 2013-07-12T06:55:44.870 回答