×îÖÕЧ¹ûͼ£º

Äѵ㣺 ¶¨Î»£¬Æäʵ²»ÄÑ£¬ È¡µÃ¸¸ÔªËØ£¨Ê¡£©µÄλÖã¬È»ºóÉèÖà ÊУ¨³õʼÒþ²Ø£©µÄλÖà = ¸¸ÔªËØÎ»ÖÃÆ«ÒÆn¸öpx
idΪpop µÄdivÊÇģʽ´°¿Ú
˵һÏÂÁ÷³Ì°É
1.ajax¶Á³öËùÓÐÊ¡ÊÐ
2.ÊзÅÔÚÒ»¸ödivÀïÃæ£¬³õʼÊÇÒþ²ØµÄ£¬È»ºó¸øÃ¿Ò»¸öÊ¡¼ÓÒ»¸öonclickʼþ£¬¿ØÖÆÕâ¸öÊ¡µÄÊÐÏÔʾ»¹ÊÇÒþ²Ø
3.Íê³É¡£
˵µÃ¼òµ¥Á˵㣬²»¹ý¿´´úÂë¾Í¿´Ã÷°×ÁË£¡Óв»Ã÷°×¿ÉÒÔÔÚÕâÀïÁôÑÔ£¬ÎÒ»á¹Ø×¢£¡
html´úÂë
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="test_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 type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
    
    <script>
    var xmlHttp;
function createXMLHttpRequest()
{
    if(window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
    }
}
function startRequest()
{
    createXMLHttpRequest();
    try
    {       
        xmlHttp.onreadystatechange = handleStateChange;
        xmlHttp.open("GET", "Default.aspx?ct=1", true);
        xmlHttp.send(null);
    }
    catch(exception )
    {
    alert(exception);
        alert("ÇëÉÔºòÔÙÊÔ!");
    }
}
function handleStateChange()
{    
    if(xmlHttp.readyState == 4)
    {        
        if (xmlHttp.status == 200 || xmlHttp.status == 0)
        {   
            var param = xmlHttp.responseText;   
            $("#divlist").append(param);
            alert(param);
        }
    }
}
 function cc(){
    $('#divdialog').fadeIn('fast');
    $('#pop').css({'width': '100%','height': '100%','display': 'inline'});
    startRequest();
    }
    
    function selectitem(obj){
    $("#txt1").val(obj);
    }
  
    function showc(obj,objname){
    if($("#divct"+obj).text() == ""){
    selectitem(objname); //Èç¹ûûÓÐÊУ¬¾ÍÑ¡ÔñÊ¡
    }else{
      var pos = $("#apro"+obj).position();   //¸¸ÔªËØÎ»Öà  
      var left = pos.left+40+ "px"; //Æ«ÒÆÁ¿
      var top = pos.top+15+ "px";
      $("#divct"+obj).css({
        "top": top,
        "left":left,
        "background":"#F3FBEA",
        "color":"#666600"
    }).show();
    
    setTimeout(hidect2(obj),4000);//4Ã붨ʱ¹Ø±Õ
    }   
    }
    
    function hidect(obj){
    $("#divct"+obj).hide();
    }
    function hidect2(obj){
    return function(){hidect(obj);}
    }
    function closect(){
    $("#divdialog").hide();
    $('#pop').css({'width': '0','height': '0','display': 'none'});
    }
   
   
    
    </script>
    
<style>
.proul{list-style:none}
.proul li{width:100px;height:30px;float:left; cursor:pointer}
.ctul{list-style:none}
.ctul li{width:100px;height:30px;float:left; cursor:pointer}
.ctdiv{display:none;position: absolute; border:1px #666600 solid; width:auto; height:auto}
.dtl{font-size:12px; color:White; font-weight:bold; cursor:pointer}
.f_r{float:right}
.f_l{float:left}
</style>
</head>
<body>
    <form id="form1" runat="server">
    
        <input id="Button1" type="button" value="Ñ¡ÔñµØÇø" onclick="cc();" />
    <div id="pop" style="background-color:#000000;position: absolute ;top:0;left:0;z-index:1;display:none;filter:Alpha(opacity=30);"></div>
    
    <div id="divdialog" style="border: #4b8500 1px solid;display: none; left: 217px; background-image: url(../images/t_bg.jpg); width: 477px;  background-repeat: repeat-x;
        position: absolute; top: 172px; height: 350px; background-color: #faffeb; z-index:99999">
        <div style="padding-right: 5px; overflow: hidden; line-height: 25px; height: 25px;text-align: right">
            <span  style="float: left; padding:4px 0px 4px 0px" ><img src="../images/t_bg_l.gif" width="16" height="16" /></span>
            <span class="dtl f_l">ÇëÑ¡ÔñµØÇø</span>            
            <span onclick="closect();" class="dtl f_r">[¹Ø±Õ]</span>
               <span onclick="closect();$('#txt1').val('²»ÏÞ');" class="dtl f_r">[²»ÏÞ]</span>
        </div>
        <div id="divlist" style="font-size: 12px; margin: 0px auto; width: 462px; color: #000; height:320px; overflow:scroll; text-align:left" runat="server">
            
            </div>
            
    </div>
        <input id="txt1" type="text" />
    </form>
</body>
</html>
 
ºǫ́Êä³ö´úÂë
private void Bind()
    {
        IList<heyjob.Model.c_Province> listP = bllP.DataTableToList(bllP.GetAllList().Tables[0]);
        string arr = string.Empty;
        string ct = string.Empty;
        for (int i = 0; i < listP.Count; i++)
        {
            IList<heyjob.Model.c_City> listC = bllC.DataTableToList(bllC.GetList("provinceid='" + listP[i].ProvinceID + "'").Tables[0]);
            arr += "<ul class='proul'><div id='divpro" + listP[i].ProvinceID + "'>";
            arr += "<li><a id='apro" + listP[i].ProvinceID + "' onclick=showc('" + listP[i].ProvinceID + "'" +",'" + listP[i].ProvinceName + "');>" + listP[i].ProvinceName + "</a></li>";
            arr += "</div></ul>";
            ct += "<div class='ctdiv' id='divct" + listP[i].ProvinceID + "'><ul class='ctul'>";
            for (int j = 0; j < listC.Count; j++)
            {
                if (listC.Count > 0)
                {
                    if (listC[j].ProvinceID == listP[i].ProvinceID)
                    {
                        if (j == 0)
                        {
                            ct += listP[i].ProvinceName + "<br/><br/>";
                        }
                        ct += "<li><a onclick=selectitem('" + listC[j].CityName + "');>" + listC[j].CityName + "</a></li>";
                    }
                }
            }
            ct += "</ul></div>";
            arr += ct;
        }
        Response.Write(arr);
        Response.End();
    }