2013-11-27 20 views
0

嗨在magento中选择导航菜单后,如何获取onchange值? 我试图在topmenu.phtml下面的代码,但它不能正常显示页面没有找到 但它工作不正常。我该怎么办?如何在magento中选择导航菜单后获得更改值?

+0

这里是topmenu.phtml <选择的id =” nav“class =”nav“onchange =”setLocation(this.value)“> <?php echo $ _menu?> –

回答

0

,你可以尝试这样的事情

<select id="nav" class="nav" onchange="if (this.value) window.location.href=this.value"> 
+0

我试图但在网址工作404找不到1 –

+0

什么是您的选择选项的价值 –

+0

选择选项值获取名称 –

0

更新Topmenu.php代码与下面的代码。

删除此:

$html .= '<option ' . $this->_getRenderedMenuItemAttributes($child) . '>'; 
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>'; 

if ($child->hasChildren()) { 
    if (!empty($childrenWrapClass)) { 
     $html .= '<div class="' . $childrenWrapClass . '">'; 
    } 
    $html .= '<ul class="level' . $childLevel . '">'; 
    $html .= $this->_getHtml($child, $childrenWrapClass); 
    $html .= '</ul>'; 
    if (!empty($childrenWrapClass)) { 
     $html .= '</div>'; 
    } 
} 
$html .= '</option>'; 

添加以下代码:

$html .= '<option value="' . $child->getUrl() . '" '>'. $this->escapeHtml($child->getName()) . '</option>'; 
if ($child->hasChildren()) { 
    $html .= $this->_getHtml($child, $childrenWrapClass); 
} 

而且更新选择onchange代码与下面的代码:

onchange="if (this.value) window.location.href=this.value" 
+0

对不起,得到错误解析错误:语法错误,意外'。'在线125 –

+0

D:\ xampp \ htdocs \ littletreasures \ app \ code \ local \ Mage \ Page \ Block \ Html \ Topmenu.php使用更新后的代码。 –

相关问题