城市/区域 二级联动下拉菜单

80酷酷网    80kuku.com

  菜单|下拉

js 代码

function GetAreaList(res1,res2)
     {
         var CityID = res1.options[res1.selectedIndex].value;
         res2.length=0;
         var ds = Property_Default.GetArea(CityID).value;
         if(ds != null&& typeof(ds) == "object" && ds.Tables != null)
         {
            if(res1.selectedIndex != 0)
            {                
                for(var i=1; i<ds.Tables[0].Rows.length; i++)
                {
                    var name=ds.Tables[0].Rows[i].AreaName;
                    var id=ds.Tables[0].Rows[i].AreaID;
                    res2.options.add(new Option(name,id));
                }
            }
            else
            {
                res2.options.add(new Option("选择区域","0"));
            }
        }
     }

cs 代码

[AjaxPro.AjaxMethod]//获得区域数据
    public DataSet GetArea(int CityID)
    {
        string str = "select * from ktv_Area where CityID=" +  CityID;
        DataSet ds = DataBase.ExeSqlda(str);
        return ds;
    }

private DataSet GetData()
    {
        string str = "select * from property_City";
        DataSet ds = DataBase.ExeSqlda(str);
        return ds;
    }

 

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: