城市联动

      城市的onchange事件

      js.Append(@"function getCity(id){");
          js.Append(@" var citycode =  document.getElementById(""Apply.City"").value;");
          js.Append(@"$.ajax({url:""" + CoreConfig.SysPath + @"Web/Firm/Apply.LoadCity.ax?code=""+citycode+"""",");
          js.Append(@"success:function(data){eval(data)");
          js.Append(@"}");
          js.Append(@"});");
          js.Append(@"}");
 

      public StringBuilder LoadCity(string code)
        {
            StringBuilder js = new StringBuilder();
            DataSet ds = new DataSet();
            ds = citydal.GetAreaList(code);
            if (ds != null)
            {
                js.Append(@"var obj=document.getElementById('Apply.Area');");
                js.Append(@"obj.options.length=0; ");
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    js.Append(@"obj.options.add(new Option(""" + dr["Name"].ToString() + @""",""" + dr["Code"] + @"""));");
                }
            }
            return js;
        }
 

 

posted @ 2015-12-11 20:11  YueYuePeng  阅读(127)  评论(0编辑  收藏  举报