如何用js

mark271828 2007-05-15 12:06:08
我有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,哪位帮忙看下
...全文
252 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2007-05-15
  • 打赏
  • 举报
回复
<script>
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.");
}

}
</script>
<input id=textfield22 onblur="country()">
<input id=countrycode>
mark271828 2007-05-15
  • 打赏
  • 举报
回复
////////////
mark271828 2007-05-15
  • 打赏
  • 举报
回复
问题已经解决了,不过还是谢谢你
孟子E章 2007-05-15
  • 打赏
  • 举报
回复
<script src="xxxxxxx.js"></script>
<input id=textfield22 onblur="country()">
<input id=countrycode>


不知道你要干什么
mark271828 2007-05-15
  • 打赏
  • 举报
回复
好象不能运行,另外js文件的内容最好不要直接写在输入框的页面中

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧