简体   繁体   English

1页上有2个select下拉菜单的问题

[英]issue with 2 select dropdowns on 1 page

I have an issue in Joomla where I have a module that creates a select dropdown list from a menu. 我在Joomla中遇到问题,我在其中有一个模块,该模块可从菜单创建选择下拉列表。

Works great if I have just 1 dropdown on a page - if I have 2 dropdowns by creating another instance of the module pulling from another menu (ie dropdown1 & dropdown2) the page crashes. 如果页面上只有1个下拉菜单,则效果很好-如果通过创建从另一个菜单(即dropdown1&dropdown2)提取的模块的另一个实例而具有2个下拉菜单,则页面崩溃。

I was wondering if it is to do with the following code in my modules default.php tmpl file: 我想知道这是否与模块default.php tmpl文件中的以下代码有关:

<?php
// No direct access.
defined('_JEXEC') or die;
?>
<form name="SelMenFrm">
<?php if($params->get('showLabel') == 1) echo $params->get('selectLabel')."&nbsp;"; ?>
<select name="SelMenSel" class="<?php echo $class_sfx;?>" onchange="javascript:location.href=document.SelMenFrm.SelMenSel.options[document.SelMenFrm.SelMenSel.selectedIndex].value;">
<option><?php echo $params->get('topText');?></option>
<?php
foreach ($list as $i => &$item) :
    // Determine if item shoud be set as selected
    $selected = "";
    if (($item->home == 0) && ($item->id == $active_id)) $selected = "selected=\"selected\"";
    // Set indent
    if ($item->level == 1) $indent = "";
    if ($item->level == 2) $indent = "&nbsp;-&nbsp;";
    if ($item->level == 3) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;";
    if ($item->level == 4) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;";
    if ($item->level == 5) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;";
    if ($item->level == 6) $indent = "&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;&nbsp;-&nbsp;";
    echo "<option ".$selected."value=\"".$item->flink."\">".$indent.$item->title."</option>";
endforeach;
?>
</select></form>

Any ideas/help would be really appreciated ;) 任何想法/帮助将不胜感激;)

Thanks 谢谢

$indent = str_repeat("&nbsp;",($item->level>=1?($item->level-1):0));

那个怎么样?

if you're loading the modules with this code: 如果您要使用以下代码加载模块:

<select name="SelMenSel" class="<?php echo $class_sfx;?>" onchange="javascript:location.href=document.SelMenFrm.SelMenSel.options[document.SelMenFrm.SelMenSel.selectedIndex].value;"

then they can't work, as they would have the same id and onchange is relying on the id to identify the select: document.SelMenFrm.SelMenSel 那么它们将无法工作,因为它们将具有相同的ID,并且onchange依赖ID来标识选择内容:document.SelMenFrm.SelMenSel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM