文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>生成联动菜单的函数

生成联动菜单的函数

时间:2007-03-16  来源:niohe


// 生成联动菜单的函数
function getunitepmenu($parray,$selectname,$selectid,$selectedid=0){//获取父级下拉菜单
        $options='';
        $options.=".$selectname." id=".$selectid." ōnChange='change(this.options.selectedIndex);'>\n";
        foreach ($parray as $arr){
                if ($arr['channelid']==$selectedid){
                        $options.=".$arr['channelid']." selected='selected'>".$arr['channelname']."\n";
                }else {
                        $options.=".$arr['channelid'].">".$arr['channelname']."\n";
                }
        }
        $options.="\n";
        return $options;
}
function getunitemenu($parray,$array,$selectname,$selectid,$pselectname,$selectedid=0){//获取子级下拉菜单
        $options='';
        $options.=".$selectname." id=".$selectid.">\n";
        $options.="\n";
        $options.=EOT
scrīpt language="javascrīpt">
    var groups=document.getElementById("$pselectname").options.length;
    var group=new Array(groups);
    for (var i=0;igroups;i++) group=new Array();\n
EOT;
    $i=0;
    foreach ($parray as $arr){
            $j=0;
              foreach ($array as $arr1){
                      if ($arr1['channelid']==$arr['channelid']){
                              $options.=" group[$i][$j]=new Option('".$arr1['classname']."','".$arr1['classid']."');\n";
                      }else {
                              continue;
                      }
                      $j++;
          }
        $i++;
    }
    $options.=OET
    for (var i=0;igroup[0].length;i++)
    {
      document.getElementById("$selectname").options = new Option(group[0].text,group[0].value);
    }
    function change(e)
    {
      document.getElementById("$selectname").length = 0;
      for (var i=0;igroup[e].length;i++)
      {
         document.getElementById("$selectname").options = new Option(group[e].text,group[e].value);
      }
    }
    x=document.getElementById("channelid").options.selectedIndex;
    //alert(x);
    change(x);
    isselected(x);
    function isselected(x){
      for (var i=0;igroup[x].length;i++)
      {
        if(group[x].value=='$selectedid'){
          //alert(i);
          document.getElementById("$selectname").options.selected="selected";
        }
      }
    }
/scrīpt>\n
OET;
    return $options;
}


相关阅读 更多 +
排行榜 更多 +
翌日波奇狗的历险记手机版下载

翌日波奇狗的历险记手机版下载

休闲益智 下载
怪兽远征安卓版下载

怪兽远征安卓版下载

角色扮演 下载
谷歌卫星地图免费版下载

谷歌卫星地图免费版下载

生活实用 下载