如何用js
我有2个输入框a,b,做成的效果是联动菜单方式,其中a为国家名,b为简称,调用c.js
c.js部分代码为:
String.prototype.trimstr = function()
{
return this.replace(/(^\s+)|\s+$/g,"");
}
function country()
{
var array_country=new Array("Albania","Algeria","American Samoa",...)
var array_countrycode=new Array("AL","DZ","AS","AD","AO","AI","AG"...)
for(i=0;i<array_country.length;i++)
{
if(document.getElementById("textfield22").value.trimstr().toUpperCase()==array_country[i].toUpperCase())
{
document.getElementById("countrycode").value=array_countrycode[i];
}
}
if(document.getElementById("countrycode").value=="")
{
alert("pls check your spelling,country name is wrong.");
}
}
不知道如何设置a,b,哪位帮忙看下