// 插入 其余选项。 for(var i = 0; i < itemCount; i++) { itemSelect.options[itemSelect.options.length] = new Option(itemList[i][textFieldName],itemList[i][valueFieldName]); } } } // 根据给定 selectId 删除其下全部选项。 // selectId: 给定下拉选框 Id。 function ClearOptions( selectId ) { var oSelect = document.getElementById(selectId); oSelect.selectedIndex = 0; oSelect.options.length = 0; }
function CountryChange(countryID) { var text = document.getElementById("txtNum"); text.value = ""; AjaxPCC.GetZipCode(countryID,CallBack_Code); } function CallBack_Code(response) { var value = response.value; var text = document.getElementById("txtNum"); if(value != null) { text.value = value; } } </script>
var _cityID ;
function ProvinceChange(provinceID)
{
// 清空 市。
ClearOptions("ddlCity");
// 清空 县。
ClearOptions("ddlCountry");
if(provinceID != "0")
{
AjaxPCC.GetCityInfo(parseInt(provinceID),CallBack_province)
}
}
function CallBack_province(response)
{
if(response.error != null)
{
alert(response.error);
}
FillInOptionsOnResponse(response.value, "ddlCity", "CityName", "CityID", new Option("<-- 请选择 -->", 0));
}
function CityChange(cityID)
{
// 清空 县。
ClearOptions("ddlCountry");
_cityID = cityID;
if(cityID != "0")
{
AjaxPCC.GetCountryInfo(parseInt(cityID),CallBack_city)
}
}
function CallBack_city(response)
{
if(response.error != null)
{
alert(response.error);
}
FillInOptionsOnResponse(response.value, "ddlCountry", "CountyName", "CountyID", new Option("<-- 请选择 -->", 0));
}
// 当得到响应值时 填充 给定下拉选框。
// responseValue: 其 .NET 类型需为 System.Data.DataTable 或 System.Data.DataView
// selectId: 给定下拉选框 Id。
// textFieldName: 文本字段名。
// valueFieldName: 值字段名。
// firstOption: 首选项[选填]。
function FillInOptionsOnResponse(responseValue, strSelectId, textFieldName, valueFieldName, firstOption)
{
// 情况 1:返回 DataView 。
var itemList = responseValue;
var itemCount = itemList.length; // 情况 2:返回 DataTable 。
if (itemCount == undefined)
{
itemCount = itemList.Rows.length;
itemList = itemList.Rows;
} // 填充下拉框。
if (itemCount > 0)
{
// 获得 下拉框对象。
var itemSelect = document.getElementById(strSelectId);
// 插入 首选项。
if (firstOption != undefined && firstOption != null)
{
itemSelect.options[0] = firstOption;
itemSelect.options[0].selected = true;
}
// 插入 其余选项。
for(var i = 0; i < itemCount; i++)
{
itemSelect.options[itemSelect.options.length] = new Option(itemList[i][textFieldName],itemList[i][valueFieldName]);
}
}
}
// 根据给定 selectId 删除其下全部选项。
// selectId: 给定下拉选框 Id。
function ClearOptions( selectId )
{
var oSelect = document.getElementById(selectId);
oSelect.selectedIndex = 0;
oSelect.options.length = 0;
}
function CountryChange(countryID)
{
var text = document.getElementById("txtNum");
text.value = "";
AjaxPCC.GetZipCode(countryID,CallBack_Code);
}
function CallBack_Code(response)
{
var value = response.value;
var text = document.getElementById("txtNum");
if(value != null)
{
text.value = value;
}
}
</script>
太郁闷了,我就把那个安全检测的关闭了。后来我发现其实这样写Ajax改动态空间的值,是个误区,不能这么做。
另外改变了下拉框的值后,你只能传递参数给后台,不能用request.form或这drp.selectValue等,下拉框的传值我在好几个地方都看到,只能通过回调参数来传.
惟一安全且被认可的方法就是加到回调参数里,另外如果说是安全性问题,你把它说的那个安全开关关闭了,或者把空间的viewstate关闭了看下。
我那天被整郁闷了的,穷地方又上不起网。
真郁闷xeppp的方法我没试不过应该也有那个问题吧
没有的话那是什么原因造成的呢