当前位置: 首页 > 图文教程 > 网络编程 > PHP > 用php实现简单的滑动菜单

PHP
PHP实例教程:Output Control输出函数
memcached和mysql主从环境下PHP开发
基于LAMP架构设计的WEB框架
PHP代码:验证IPV6地址是否合法的正则
PHP环境快读搭建绿色软件包PHPnow
PHP教程:$_SERVER的详细参数整理
php获取url字符串截取路径的文件名和扩展名的函数
在命令行下运行PHP脚本[带参数]的方法
PHP 实用代码收集
PHP 时间转换Unix时间戳代码
关于php fread()使用技巧
PHPMailer 中文使用说明小结
php addslashes和mysql_real_escape_string
php cout<<的一点看法
PHP 变量的定义方法
php学习之 认清变量的作用范围
php 静态变量与自定义常量的使用方法
认识并使用PHP超级全局变量
通过具体程序来理解PHP里面的抽象类
php读取xml实例代码

PHP 中的 用php实现简单的滑动菜单


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 43 ::
收藏到网摘: n/a

<style>
table {font-size = 9pt}
td {height = 20px}
</style>
<body>
<span id="menus"></span>
<span id="view"></span>
</body>
<script for=pad event=onclick>
// 大类节点点击响应
for(var i=1;i<this.parentElement.rows.length;i+=2)
 this.parentElement.rows[i].style.display = "none";
this.parentElement.rows[this.rowIndex+1].style.display='block';
view.innerHTML = this.v1 +":"+ this.v2; // 根据大小类自行构造相应动作
</script>
<script for=bar event=onclick>
// 小类节点点击响应
view.innerHTML = this.v1 +":"+ this.v2; // 根据大小类自行构造相应动作
</script>
<script>
/**
* 产生菜单的html代码串
* 入口参数为菜单默认打开的大类号
*/
function menu(n) {
  this.ar = new Array(
  /**
   * 参数数组
   * 列1:大类
   * 列2:小类
   * 列3:标题
   */
  new Array(1,0,"大类一"),
  new Array(1,1,"小类一"),
  new Array(1,2,"小类二"),
  new Array(2,0,"大类二"),
  new Array(2,1,"小类一"),
  new Array(2,2,"小类二"),
  new Array(2,3,"小类三"),
  new Array(3,0,"大类三"),
  new Array(3,1,"小类一"),
  new Array(3,2,"小类二"),
  new Array(4,0,"大类四"),
  new Array(4,1,"小类一"),
  new Array(4,2,"小类二"),
  new Array(4,3,"小类三")
  );
  this.width =120;
  this.bgcolor = "#f0f0f0";
  this.bordercolorlight = "#c0c0c0";
  this.bordercolordark = "#FFFFFF";
  this.tr_bgcolor = "#d0d0d0";
  var s = "<table border=1 align=center width="+this.width+" bgcolor="+this.bgcolor+" bordercolorlight="+this.bordercolorlight+" bordercolordark="+this.bordercolordark+" CELLPADDING=0 CELLSPACING=0>"
  for(var i=0;i<this.ar.length;i++) { // 构造菜单的html结构,其中将大小类编号作为自定义参数,以便事件响应时使用。
    if(this.ar[i][1] == 0) {
      if(i > 0)
        s += "</table></td></tr>";
      var vk = this.ar[i][0]==n?"block":"none";
      s += "<tr id='pad' bgcolor="+this.tr_bgcolor+" v1="+this.ar[i][0]+" v2="+this.ar[i][1]+"><td align=center>"+this.ar[i][2]+"</td></tr><tr style='display:"+vk+"'><td><table width=100%>";
    }else
      s += "<tr><td id='bar' v1="+this.ar[i][0]+" v2="+this.ar[i][1]+">"+this.ar[i][2]+"</td></tr>";
  }
  s += "</table></td></tr></table>";
  return s;
}
/*** 创建菜单 ***/
menus.innerHTML = menu(4);
</script>