[英]issue with 2 select dropdowns on 1 page
我在Joomla中遇到问题,我在其中有一个模块,该模块可从菜单创建选择下拉列表。
如果页面上只有1个下拉菜单,则效果很好-如果通过创建从另一个菜单(即dropdown1&dropdown2)提取的模块的另一个实例而具有2个下拉菜单,则页面崩溃。
我想知道这是否与模块default.php tmpl文件中的以下代码有关:
<?php
// No direct access.
defined('_JEXEC') or die;
?>
<form name="SelMenFrm">
<?php if($params->get('showLabel') == 1) echo $params->get('selectLabel')." "; ?>
<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 = " - ";
if ($item->level == 3) $indent = " - - ";
if ($item->level == 4) $indent = " - - - ";
if ($item->level == 5) $indent = " - - - - ";
if ($item->level == 6) $indent = " - - - - - ";
echo "<option ".$selected."value=\"".$item->flink."\">".$indent.$item->title."</option>";
endforeach;
?>
</select></form>
任何想法/帮助将不胜感激;)
谢谢
$indent = str_repeat(" ",($item->level>=1?($item->level-1):0));
那个怎么样?
如果您要使用以下代码加载模块:
<select name="SelMenSel" class="<?php echo $class_sfx;?>" onchange="javascript:location.href=document.SelMenFrm.SelMenSel.options[document.SelMenFrm.SelMenSel.selectedIndex].value;"
那么它们将无法工作,因为它们将具有相同的ID,并且onchange依赖ID来标识选择内容:document.SelMenFrm.SelMenSel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.