我有三个DIV层对应三个服务器控件按钮,点击一个按钮弹出对应DIV层进行编辑,其他层除非点击其他按钮否则均不出现,请问这个代码怎么写啊?

解决方案 »

  1.   

    <div id="pdiv" style="display:none"></div>
    <input type="button" onclick="pop();" />
    <script>
    function pop()
    {
        document.getElementById("pdiv").style="block";
        //其他两个设置为"none";
    }
    </script>
      

  2.   

       <script type="text/javascript">
          function edit(divid)
          {
           var div = document.getElementById(divid);
           if(div.style.display=="none")
           {
            document.getElementById(divid).style.display="";
           }
           else
           {
            document.getElementById(divid).style.display="none";
           }
          }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="div1" style="display:none;">ffffffffff</div>
        <div id="div2" style="display:none;">ffffffffff</div>
        <div id="div3" style="display:none;">ffffffffff</div>
        <input type="button" value="click " onclick="edit('div1')" />
        <input type="button" value="click " onclick="edit('div2')" />
        <input type="button" value="click " onclick="edit('div3')" />
        </form>
    </body>
    </html>
      

  3.   

    div隐藏显示
    function test()  
    {  
      var div=document.getElementById("div1")  
      div.style.display=div.style.display=="none"?"block":"none";  
    }Page.RegisterStartUpScript("key",@"getElementById('div').style.display = 'none';")  
    <div id="div1" runat="Server">  
    </div>  
    div1.Style["Display"] = "Block"; //显示
    div1.Style["Display"] = "None"; //隐藏
      

  4.   


    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!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 runat="server">
        <title>无标题页</title>    <script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function(){
               $("input[name='btnDiv']").click(function(){
                  var idStr = $(this).attr("id");              
                  var a = idStr.split("_");             
                  
                   $("div[name='divShow']").hide();
                  
                  $("#div_"+a[1]).show();
               });          
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
       
         <div id="div_1" name="divShow" style="display:none;">1</div>
         <div id="div_2" name="divShow" style="display:none;">2</div>
         <div id="div_3" name="divShow" style="display:none;">3</div>
            <input id="Button_1" name="btnDiv" type="button" value="button" />
            <input id="Button_2" name="btnDiv" type="button" value="button" />
            <input id="Button_3" name="btnDiv" type="button" value="button" />
        
        </form>
    </body>
    </html>
      

  5.   

    1F你的意思不符合我的题,我要的是点击了DIV里面的按钮都不会跳到别的页面去
      

  6.   

    2F3F你们的都只是DIV的显示与隐藏,我要的是能打开一个DIV,然后在里面编辑,编辑完了要转到别的页面的时候才转到别的页面去——————4F你的代码没有反应
      

  7.   


    <!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>ShowDiv</title>
    <script type="text/javascript">
            function showTip(showdiv) {
                var tipBox = document.getElementById(showdiv);
                for(var i=1;i<4;i++)
                {
                    var emp="show"+i;
                    if(showdiv==emp)
                    {
                        tipBox.style.display = "block";
                    }
                    else
                    {
                        document.getElementById(emp).style.display="none";
                    }
                }
            }
        </script></head><body>
    <form>
    <div id="show1" name="show1" style="display:none;">show1</div>
    <div id="show2" name="show2" style="display:none;">show2</div>
    <div id="show3" name="show3" style="display:none;">show3</div>
    <input id="Button_1" name="btnDiv1" type="button" value="button1" onclick="showTip('show1')"/>
    <input id="Button_2" name="btnDiv2" type="button" value="button2" onclick="showTip('show2')"/>
    <input id="Button_3" name="btnDiv3" type="button" value="button3" onclick="showTip('show3')"/>
    </form>
    </body>
    </html>
      

  8.   

    8F你的代码能用,可是还是跟前面的那些朋友一样,在你的DIV层里面放一个按钮点击事件就会发现点一下就跳回默认页面,要想继续在里面编辑就得再次点击才行
      

  9.   

    终于有高手帮我搞定了,把每个DIV单独放在一个页面内,主页面放一个iframe指向要默认显示的页面,编写点击事件:function sameMethod(i){
                  if(i==1)
                   {
                    document.getElementById("mainframe").src="Management/UserEdit.aspx";
                   }
                  if(i==2)
                  {
                    document.getElementById("mainframe").src="Management/NewsEdit.aspx";
                  }
                 if(i==3)
                  {
                    document.getElementById("mainframe").src="Management/Update.aspx";
                  }
               }
    还是希望有人能帮我写个能把三个DIV放在同一个页面进行编辑的的代码,谢谢大家了哈