Js脚本问题 - Web 开发 / Ajax
var _thisCountry = null;
var _thisProvince = null;
var _thisCity = null;
function deleteAllOption(obj)
{
obj.length = 0;
}
function addOption(obj,cityName,ovalue)
{
var op = document.createElement("option");
op.value = cityName;
obj.appendChild(op);
op.innerHTML=ovalue;
}
function powercityinit(Country,Province,City)
{
_thisCountry = document.getElementById(Country);
_thisProvince = document.getElementById(Province);
_thisCity = document.getElementById(City);
deleteAllOption(_thisCountry);
deleteAllOption(_thisProvince);
deleteAllOption(_thisCity);
setCountry();
setProvince(_thisCountry.value);
setCity(_thisProvince.value);
resetAllWidth();
}
function resetAllWidth()
{
resetWidth(_thisCountry);
resetWidth(_thisProvince);
resetWidth(_thisCity);
}
function resetWidth (oObject)
{
var iMaxSize = 0;
var iLength;
for (var i = 0, j = oObject.options.length;i < j; i++)
{
iLength = oObject.options[i].value.length;
if (iLength > iMaxSize)
{
iMaxSize = iLength;
}
}
}
///设置默认国家
function setDefaultCountry(str)
{
_thisCountry.value=str;
setProvince(_thisCountry.value);
setCity(_thisProvince.value);
}
///设置默认省
function setDefaultProvince(str)
{
_thisProvince.value=str;
setCity(_thisProvince.value);
}
//设置默认市
function setDefaultCity(str)
{
_thisCity.value=str;
}
function setCountry()
{
addOption(_thisCountry,"","请选择");
addOption(_thisCountry,"中国","中国");
addOption(_thisCountry,"海外","海外");
}
function setProvince(str)
{
deleteAllOption(_thisProvince);
if(''==str)addOption(_thisProvince,'','请选择');
if('中国'==str)addOption(_thisProvince,'','请选择')
if('中国'==str)addOption(_thisProvince,'浙江省','浙江省');
if('中国'==str)addOption(_thisProvince,'江苏省','江苏省');
if('海外'==str)addOption(_thisProvince,'','请选择')
}
function setCity(str)
{
deleteAllOption(_thisCity);
if(''==str)addOption(_thisCity,'','请选择');
if('浙江省'==str)addOption(_thisCity,'','请选择');
if('浙江省'==str)addOption(_thisCity,'杭州市','杭州市');
if('浙江省'==str)addOption(_thisCity,'宁波市','宁波市');
if('浙江省'==str)addOption(_thisCity,'台州市','台州市');
if('浙江省'==str)addOption(_thisCity,'金华市','金华市');
if('江苏省'==str)addOption(_thisCity,'','请选择');
if('江苏省'==str)addOption(_thisCity,'南京市','南京市');
if('江苏省'==str)addOption(_thisCity,'杨州市','杨州市');
}
上面一直有个问题 大哥说的时候俺也没听懂 我看了半天也不知道哪有问题
求各位看看?
------解决方案--------------------
不知所云,鉴订完毕!