如何用javascript来过滤Listbox中的重复项 思想:建立一个数组,往数组中存元素的时候遍历所有数组元素判断是否有重复元素,没有就不存 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script language="JavaScript"><!--function add(src){ if(event.keyCode!=13){ document.getElementById("divMsg").innerText=""; return false; } var dlt=document.getElementById("dltShow"); for(var i=0;i<dlt.options.length;i++) if(dlt.options[i].value.toLowerCase()==src.value.toLowerCase()){ document.getElementById("divMsg").innerText="该项已经存在!"; return false; } var opt = document.createElement("option"); dlt.add(opt); opt.value=src.value; opt.text=src.value; dlt.selectedIndex=dlt.options.length-1; src.value="";}//--></script><body onload="document.getElementById('txtInput').focus()"><input id="txtInput" type="text" style="width:100px" onkeypress="add(this)"><select id="dltShow" style="width:100px"></select><div style="width:600; height:20;" id="divMsg"></div></body> js原型的问题,很奇怪 JS难题,frame页中函数无法执行 网页缩略图 推荐一本JavaScript的书,顺便给贴点js的面试题目,谢谢!!! 在IE中添个按扭,点击此按扭弹出IE中的页面设置,怎么做????? js获取url的参数????急!!!! 如何取本地的一个文件和更改其后缀名,然后运行呢? 下载文件保存问题,在线等待,解决即给分 关于checkbox全选和全撤的问题 怎样用js写一个终止程序,类似asp的response.end 请问怎样下载框架网站的网页? 请问javascript的得到文件的大小的语句怎么写? 谢谢
<!--
function add(src){
if(event.keyCode!=13){
document.getElementById("divMsg").innerText="";
return false;
}
var dlt=document.getElementById("dltShow");
for(var i=0;i<dlt.options.length;i++)
if(dlt.options[i].value.toLowerCase()==src.value.toLowerCase()){
document.getElementById("divMsg").innerText="该项已经存在!";
return false;
}
var opt = document.createElement("option");
dlt.add(opt);
opt.value=src.value;
opt.text=src.value;
dlt.selectedIndex=dlt.options.length-1;
src.value="";
}
//-->
</script>
<body onload="document.getElementById('txtInput').focus()">
<input id="txtInput" type="text" style="width:100px" onkeypress="add(this)">
<select id="dltShow" style="width:100px"></select>
<div style="width:600; height:20;" id="divMsg"></div>
</body>