Atlas, Ajax,ASP.NET, .NET, Javascript, PHP, C#
Johson点滴 Know What ! Know How ! Know Why ! Know Working !!! If you think you can ,You can !

ajax实现三级联动/ajax实现无刷联动列表/

一个Ajax无刷的代码,供大家学习和交流,这个是在vs2003下使用AJAX的代码,如果大家有好的想法请多提意见,谢谢!!
有兴趣的可以看看这个页面http://shouhou.xx10000.com/result/find.aspx


省份:
城市: 地区:

  [Ajax.AjaxMethod]
  public string bind_ddl1()
  {
   string str = "";               
  }

  // 城市:二级下拉
  [Ajax.AjaxMethod]
  public string bind_ddl2(string id)
  {
   string sql;
   if(id=="0")
   {
    sql="select cityID,city from city";
   }
   else
   {
    sql="select cityID,city from city where father='"+id+"'";
   }
   DataTable dt = sts.getDataTable(sql);
   string str = "";                     
  }

  // 地区:三级下拉
  [Ajax.AjaxMethod]
  public string bind_ddl3(string id)
  {
   string sql;
   if(id=="0")
   {
    sql="select areaID,area from area";
   }
   else
   {
    sql="select areaID,area from area where father='"+id+"'";
   }
   DataTable dt = sts.getDataTable(sql);
   string str = "";                     
  }

//绑定省份列表事件
function bindPRO_all()
{
 $("projs").innerHTML = inforesult.bind_ddl1().value;
}

//城市列表事件
function chanSel_province(obj)
{
 projsid = obj.options[obj.selectedIndex].value
 $("cityjs").innerHTML = inforesult.bind_ddl2(projsid).value; 
}

//地区列表事件
function chanSel_city(obj)
{
 cityjsid = obj.options[obj.selectedIndex].value
 $("areajs").innerHTML = inforesult.bind_ddl3(cityjsid).value;
}

public DataTable getDataTable(String sql)
  {
   //把SQL执行的结果封装在一个DataTable中,并返回该DataTable
   DataObject ado=new DataObject();
   DataTable dt;
   try
   {
    dt=new DataTable();
    ado.open();
    dt= ado.DTTransSqlQuery(sql);
   }
   catch(Exception e)
   {
    
    new SimpleTools().processException("01",e.Message);
    throw(new Exception(e.Message));
   }
   finally
   {
    ado.close();
   }
   return dt;
  }

posted on 2007-08-28 10:14  Johson  阅读(2473)  评论(3编辑  收藏  举报