主题:  [求助]有关某个代码~~~

ritsuka

职务:普通成员
等级:1
金币:0.0
发贴:2
#12006/4/24 22:10:04
请问用鼠标点击表格某一行,然后表格下会伸展出他里面的详细内容,再点击,他又会缩回去,这一个的代码是什么?
我表达能力差,不知道有没有人看明白,汗……



yiliaocheng

职务:普通成员
等级:2
金币:2.0
发贴:631
#22006/4/25 16:39:40
就是可折叠的菜单。代码如下:
function showtb(tbnum){whichEl = eval("tbtype" + tbnum);if (whichEl.style.display == "none"{eval("tbtype" + tbnum + ".style.display=\"\";";}else{eval("tbtype" + tbnum + ".style.display=\"none\";";}}
像这样调用:
<tr style="CURSOR: hand" onclick=showtb(1) class=td2>
<td width="150" background="pic/admin/admin_left_2.gif" height="25" align="center">
    <p align="left">&nbsp; 常规设置</td>
</tr>
<tr id=tbtype1 style='display:none'>
<td bgcolor="#cad6eb" width="150">
<p style="margin: 4; ">
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a> <a href="adminright.asp?action=bbs">常规信息设置</a><br>
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a>
<a href="adminright.asp?action=openbbsyn">论坛开关设置</a><br>
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a>
<a href="adminright.asp?action=gonggaogl">公告管理</a><br>
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a>
<a href="adminfso.asp?action=setadv">帖间广告</a>/<a href="adminright.asp?action=setm">每日贴士</a>
<br>
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a>
<a href="adminright4.asp?action=style">论坛风格设置</a><br>
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a>
<a href="adminright.asp?action=lm">论坛联盟管理</a><br>
<a href="adminright3.asp?action=recycle"><img border="0" src="pic/admin/tj2.gif" align="absbottom"></a>
<a href="adminright.asp?action=ip">IP封锁与解除</a>
<br> </p></td>
</tr>



【志奇林峰】

职务:普通成员
等级:1
金币:0.1
发贴:99
#32006/4/25 20:47:49
不知道你说的是不是 树型菜单 的效果 ?
如果是的话以下代码也许能用得上,
将下列代码放到 <head> 中
<style>
<!--
#foldheader{cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
//-->
</style>
<script language="JavaScript1.2">
<!--
/** 
 *  Based on Folding Menu Tree 
 *  Dynamic Drive (www.dynamicdrive.com)
 *  For full source code, installation instructions,
 *  100's more DHTML scripts, and Terms Of
 *  Use, visit dynamicdrive.com
 *
 *  Updated to support arbitrarily nested lists
 *  by Mark Quinn (mark@robocast.com) November 2nd 1998
 */

var head="display:''"
img1=new Image()
img1.src="fold.gif"
img2=new Image()
img2.src="open.gif"

function change(){
   if(!document.all)
      return
   if (event.srcElement.id=="foldheader") {
      var srcIndex = event.srcElement.sourceIndex
      var nested = document.all[srcIndex+1]
      if (nested.style.display=="none") {
         nested.style.display=''
         event.srcElement.style.listStyleImage="url(open.gif)"
      }
      else {
         nested.style.display="none"
         event.srcElement.style.listStyleImage="url(fold.gif)"
      }
   }
}

document.onclick=change

//-->
</script>



将下列代码放到 <body> 中

ul>
   <li id="foldheader">News</li>
   <ul id="foldinglist" style="display:none">
      <li><a href="../../../www.cnn.com/index.html">CNN</a></li>
      <li><a href="../../../www.abcnews.com/index.html">ABC News</a></li>
      <li><a href="../../../www.vancouversun.com/index.html">Vancouver Sun</a></li>
   </ul>

   <li id="foldheader">Games</li>
   <ul id="foldinglist" style="display:none">
      <li><a href="../../../www.gamespot.com/index.html">GameSpot</a></li>
      <li><a href="../../../www.happypuppy.com/index.html">Happy Puppy</a></li>
      <li><a href="../../../www.gamecenter.com/index.html">Game Center</a></li>
   </ul>

   <li id="foldheader">Software</li>
   <ul id="foldinglist" style="display:none">
      <li><a href="../../../www.download.com/index.html">outer 1</a></li>
      <li><a href="../../../www.hotfiles.com/index.html">outer 2</a></li>
      <li id="foldheader">Nested</li>
      <ul id="foldinglist" style="display:none">
         <li><a href="../../../www.windows95.com/index.html">nested 1</a></li>
         <li><a href="../../../www.shareware.com/index.html">nested 2</a></li>
      </ul>
      <li><a href="../../../www.windows95.com/index.html">outer 3</a></li>
      <li><a href="../../../www.shareware.com/index.html">outer 4</a></li>
   </ul>
</ul>



ritsuka

职务:普通成员
等级:1
金币:0.0
发贴:2
#42006/4/25 23:17:24
谢谢大人,好厉害~~~
偶再慢慢研究一下~~~