<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
var s=3;
function ShowOne(k)
{
switch (k)
{
case "1": 
document.getElementById("a1").style.display='';
document.getElementById("a2").style.display='';
document.getElementById("a3").style.display='';
break;
case "2": 
document.getElementById("a1").style.display='';
document.getElementById("a2").style.display='none';
document.getElementById("a3").style.display='none';
break;
case "3": 
document.getElementById("a1").style.display='none';
document.getElementById("a2").style.display='';
document.getElementById("a3").style.display='none';
break;
case "4":
document.getElementById("a1").style.display='none';
document.getElementById("a2").style.display='none';
document.getElementById("a3").style.display='';
break;
}
}
</script>
</head><body>
<form runat="server" id="form1">
<table width="824" height="46" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('1')">全部</a></td>
    <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('2')">a1</a></td>
    <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('3')">a2</a></td>
    <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('4')">a3</a></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p><span id="a1" >
<table width="393" height="93" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#996699">fsdfasdfasdfasdf</td>
  </tr>
</table>
<br /></span>
<span id="a2">
<table width="391" height="104" border="0" cellpadding="0" cellspacing="0" bgcolor="#CC3333">
  <tr>
    <td>sadsafdsafasdfsf</td>
  </tr>
</table>
<br /></span>
<span id="a3">
<table width="395" height="88" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#FF9966">sddfsfasfasfasdf</td>
  </tr>
</table></span></form>
</body>
</html>

解决方案 »

  1.   

    function ShowOne(k)
    {
    switch( k )
    {
    case 'All':
    document.getElementById("a1").style.display='';
    document.getElementById("a2").style.display='';
    document.getElementById("a3").style.display='';
    break;
    case '2':
    document.getElementById("a1").style.display='';
    document.getElementById("a2").style.display='none';
    document.getElementById("a3").style.display='none';
    break;
    case '3':
    document.getElementById("a2").style.display='';
    document.getElementById("a1").style.display='none';
    document.getElementById("a3").style.display='none';
    break;
    case '4':
    document.getElementById("a3").style.display='';
    document.getElementById("a1").style.display='none';
    document.getElementById("a2").style.display='none';
    break; }
    }
      

  2.   

    谢谢!  
    hbhbhbhbhb1021(天外水火(我是SB,我要多努力)) ( 
    主要是页面里的a1、a2、......a69。不一定到a几呢?应该怎么写呢?谢谢!
      

  3.   

    hbhbhbhbhb1021(天外水火(我是SB,我要多努力)) (
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    var s=3;
    function ShowOne(k)
    {
    var caseI=k.substr(0,1);
    var i;
    switch (caseI)
    {
    case "1": 
    for(j=0;j<document.getElementsByTagName("span").length;j++)
    {
    eval("document.getElementsByTagName('span')["+j+"].style.display='';")
    }
    break;
    case "2": 
    var i=k.substr(1);
    for(j=0;j<document.getElementsByTagName("span").length;j++)
    {
    eval("document.getElementsByTagName('span')["+j+"].style.display='none';")
    }
    document.getElementById("a"+i).style.display='';
    break;
    }
    }
    </script>
    </head><body>
    <form runat="server" id="form1">
    <table width="824" height="46" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('1')">全部</a></td>
        <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('21')">a1</a></td>
        <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('22')">a2</a></td>
        <td align="center" bgcolor="#669999"><a href="#" onclick="ShowOne('23')">a3</a></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p><span id="a1" >
    <table width="393" height="93" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td bgcolor="#996699">fsdfasdfasdfasdf</td>
      </tr>
    </table>
    <br /></span>
    <span id="a2">
    <table width="391" height="104" border="0" cellpadding="0" cellspacing="0" bgcolor="#CC3333">
      <tr>
        <td>sadsafdsafasdfsf</td>
      </tr>
    </table>
    <br /></span>
    <span id="a3">
    <table width="395" height="88" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td bgcolor="#FF9966">sddfsfasfasfasdf</td>
      </tr>
    </table></span></form>
    </body>
    </html>
    你是a几就在ShowOne('21')传“2几”