数据库表:A 
ID  CLASS 
1    分类一 
2    分类二 
…… 
5    分类五 将A表SELECT出后输出 
<a href="#">分类一 </a> 
<a href="#">分类二 </a> 
…… 
<a href="#">分类五 </a> 我想点击各个链接,然后在当前页的某一个地方显示出一个DIV,点击不同的链接,对应ID的DIV总是在最前面显示。 DIV的内容为 
<DIV id="divIDD"> <iframe src=c.asp?id=IDD width=436 height=314 scrolling=no name=IDD border=0 frameborder=0 marginwidth=1 marginheight=1> </iframe> </div> 上面的IDD对应A表输入出的ID。 框架内容不预先加载,只在点击对应的链接的时候才加载。

解决方案 »

  1.   

    我想点击各个链接,然后在当前页的某一个地方显示出一个DIV,点击不同的链接,对应ID的DIV总是在最前面显示。 ?不需要有多个div,点击链接的时候动态改变iframe的src属性就可以了。function showDiv(id){
    document.getElementById("iframeID").src="c.asp?id="+id;
    }
      

  2.   

    看是不是你要的效果 把连接数据库改下
    <?php
    $conn=mysql_connect('localhost','root','');
    mysql_select_db('php',$conn);
    mysql_query('set names utf8');
    $sql2="select * from class ";
     $rest2=mysql_query($sql2);
    while($Row=mysql_fetch_array($rest2))
      {
         echo "<a href='#' onclick='fun($Row[id])'>".$Row['class']."</a>"."<br>";
     }
    ?>
    <style>
       .d{width:80px;
       height:100px;
       color:'blue';
       background-color:'pink';
       position:absolute;
       border:1px solid;
       cursor:pointer;
       }
    </style>
    <script>
    var zs = 0;
    function fun(v){
        var div = document.getElementById('d'+v);
        if(div == null){
            div = document.createElement('div');
            div.className='d';
            div.style.top=100+v*20
            div.style.left=200+v*10;
            div.id='d'+v;
            div.innerHTML='<DIV id="divIDD"> <iframe src=c.asp?id=v width=436 height=314 scrolling=no name=IDD border=0 frameborder=0 marginwidth=1 marginheight=1> </iframe> </div>';
            div.style.display='block';
            div.zIndex=zs;
            zs++;
            div.onclick=function(){
                div.style.zIndex=zs;
                zs++;
            }
            document.body.appendChild(div);
        }else{
            div.style.zIndex=zs;
            zs++;
        }
    }
    </script>