簡體   English   中英

1頁上有2個select下拉菜單的問題

[英]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')."&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>

任何想法/幫助將不勝感激;)

謝謝

$indent = str_repeat("&nbsp;",($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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM