`
wanguangru
  • 浏览: 19510 次
  • 性别: Icon_minigender_2
  • 来自: 苏州
最近访客 更多访客>>
社区版块
存档分类
最新评论

Ajax 联动

 
阅读更多

    
  $(document).ready(
  function() {
  var continentid = document.getElementById("").value;
  var countryid = document.getElementById("").value;
  var cityid = document.getElementById("").value;
  $.ajax({ type: "POST",
  contentType: "application/json;charset=utf-8",
  url: "/Services/CountryService.asmx/GetContinentList",
  data: "{}",
  dataType: "json",
  success: function(result) {
  ClearContinent();
  ClearCountry();
  ClearCity();
  $("").appendTo("#Continent");
  var getContinentID = document.getElementById("").value;
  if (getContinentID > 0) {
  document.getElementById("").value = getContinentID;
  }
  $.each(result.d, function() {
  if (this.Id == getContinentID) {
  $("" + this.Name + "").appendTo("#Continent");
  } else {
  $("" + this.Name + "").appendTo("#Continent");
  }
  });
  InitSelectContinent(getContinentID);
  }
  });
  }
  );   function InitSelectContinent(obj) {
  if (obj > 0) {
  CountryAjax(obj);
  }
  }   function ContinentOnchange() {
  ClearHiddenValue();
  var selectContinentId = $("#Continent").val();
  document.getElementById("").value = selectContinentId;
  CountryAjax(selectContinentId);
  }   function CountryAjax(obj) {
  ClearCountry();
  ClearCity();
  $.ajax({ type: "POST",
  contentType: "application/json;charset=utf-8",
  url: "/Services/CountryService.asmx/GetCountryListById" ,
  data: "{'continentId':" + obj + "}",
  dataType: "json",
  success: function(result) {
  $("").appendTo("#Country");
  var getCountryID = document.getElementById("").value;
  if (getCountryID > 0) {
  document.getElementById("").value = getCountryID;
  }
  $.each(result.d, function() {
  if (this.Id == getCountryID) {
  $("" + this.Name + "").appendTo("#Country");
  }
  else {
  $("" + this.Name + "").appendTo("#Country");
  }
  });
  if (getCountryID > 0) {
  CityAjax(getCountryID);
  }
  }
  });
  }   function CountryOnchange() {
  var selectcountryId = $("#Country").val();
  document.getElementById("").value = selectcountryId;
  CityAjax(selectcountryId);
  }   function CityAjax(obj) {
  ClearCity();
  $.ajax({ type: "POST",
  contentType: "application/json;charset=utf-8",
  url: "/Services/CountryService.asmx/GetCityListById",
  data: "{'countryId':" + obj + "}",
  dataType: "json",
  success: function(result) {
  $("").appendTo("#City");
  var getCityID = document.getElementById("").value;
  if (getCityID > 0) {
  document.getElementById("").value = getCityID;
  }
  $.each(result.d, function() {
  if (this.Id == getCityID) {
  $("" + this.Name + "").appendTo("#City");
  } else {
  $("" + this.Name + "").appendTo("#City");
  }
  });
  }
  });
  }
  function CityOnchange() {
  document.getElementById("").value = $("#City").val();
  }   function ClearContinent() {
  $("#Continent").empty();
  document.getElementById("").value = 0;
  }   function ClearCountry() {
  $("#Country").empty();
  document.getElementById("").value = 0;
  }   function ClearCity() {
  $("#City").empty();
  document.getElementById("").value = 0;
  }   function ClearHiddenValue() {
  document.getElementById("").value = 0;
  document.getElementById("").value = 0;
  document.getElementById("").value = 0;
  }
   
  
  
  
  
  
  
  
  
  
  
   using System;
  using Daps.Common.Utilities;
  namespace Daps.En.WebSite.Controls
  {
  public partial class CountryCtrl : System.Web.UI.UserControl
  {
  public int ContinentID
  {
  get
  {
  return Convert.ToInt32(this.Hidden_ContinentId.Value);
  }
  }         public int CountryID
  {
  get
  {
  return Convert.ToInt32(this.Hidden_CountryId.Value);
  }
  }         public int CityID
  {
  get
  {
  return Convert.ToInt32(this.Hidden_CityId.Value);
  }
  }         protected override void OnLoad(EventArgs e)
  {
  this.Hidden_GetContinentId.Value = SecurityHelper.RequestQueryNum("ContinentID").ToSt ring();
  this.Hidden_GetCountryId.Value = SecurityHelper.RequestQueryNum("CountryID").ToStri ng();
  this.Hidden_GetCityId.Value = SecurityHelper.RequestQueryNum("CityID").ToString( );
  }
  }
  }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics