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( );
  }
  }
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值