`
webcode
  • 浏览: 5947157 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

仿163填写邮件地址自动显示下拉(无优化版)

阅读更多
<iframe name="google_ads_frame" marginwidth="0" marginheight="0" src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&amp;dt=1225766926984&amp;lmt=1219829526&amp;prev_slotnames=1891601125&amp;output=html&amp;slotname=3685991503&amp;correlator=1225766926906&amp;url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1441.html&amp;ea=0&amp;ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__71.html&amp;frm=0&amp;ga_vid=1912024400.1225687205&amp;ga_sid=1225766664&amp;ga_hid=1245399751&amp;ga_fc=true&amp;flash=9.0.124.0&amp;u_h=768&amp;u_w=1024&amp;u_ah=715&amp;u_aw=1024&amp;u_cd=32&amp;u_tz=480&amp;u_java=true" frameborder="0" width="300" scrolling="no" height="250" allowtransparency></iframe> 本框内填个1,这些值都写在隐藏域了。代码里可以看到,用户输入包含在里面的时候,可以按ENTER键选中.
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<title>20060427simulate163</title>
<scriptlanguage="JavaScript"type="text/JavaScript">
<!--
functionMM_reloadPage(init){//reloadsthewindowifNav4resized
if(init==true)with(navigator){if((appName=="Netscape")&&(parseInt(appVersion)==4)){
document.MM_pgW=innerWidth;document.MM_pgH=innerHeight;onresize=MM_reloadPage;}}
elseif(innerWidth!=document.MM_pgW||innerHeight!=document.MM_pgH)location.reload();
}
MM_reloadPage(true);
//-->
</script>
<styletype="text/css">
<!--
body{
margin-left:0px;
margin-top:0px;
margin-right:0px;
margin-bottom:0px;
}

body{
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
line-height:150%;
color:#003399;
text-decoration:none;
}
a:link{
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
line-height:150%;
font-weight:normal;
color:#003399;
text-decoration:none;
}
a:visited{
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
line-height:150%;
font-weight:normal;
color:#003399;
text-decoration:none;
}
a:hover{
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
line-height:150%;
color:#0099FF;
text-decoration:underline;
}
a:active{
font-family:Arial,Helvetica,sans-serif;
font-size:12px;
line-height:150%;
color:#0099FF;
text-decoration:underline;
}

-->
</style>

</head>
<scriptlanguage="javascript">
/*
author:moonboy
本例中采用onKeyUp事件方可将录入的数据取到。在使用onKeyDown,onKeyPress事件时只是在录入第二个数据时才能取到第一个数据(idon'tkonwwhy)。
*/
//varns=String.fromCharCode(event.keyCode);

functiondroplist(){
varnp=event.keyCode;
if(np==38||np==40){

}
vartextv=document.getElementById("drop").value;//取得文本框内的值
textv=textv.toLowerCase();//全部转成小写
varuser=newArray();//初始化数组用来存储页面列表值的集合
varsortUser=newArray();//排序后的数组
varresultuser=newArray();//输出到前台的数组
varvv=document.getElementsByName("hv");//页面的值
varvvl=vv.length;//页面值的数组长度
//付值将从页面取到的集合放入user数组
for(vari=0;i<vvl;i++){
user[i]=vv[i].value;
}

sortUser=user.sort();//对数组排序

varrs=newArray();//初始化符合查询条件的数组
vartemp;
varc=0;//符合条件的数组计数

for(varj=0;j<vvl;j++){
temp=queryWord(textv,sortUser[j]);//调用queryWord函数,计算出符合条件的值
if(temp==""){
continue;
}else{
//temp=getSelect(textv,temp);
rs[c]="<trid='tv'name='tv'bgcolor='#eeeeee'><tdid='al"+c+"'onclick='onV("+c+")'style='cursor:pointer'onmouseover='alterBg("+c+",0)'onmouseout='alterBg("+c+",1)'>"+getSelect(textv,temp)+"</td></tr>";
c++;
}
}
resultuser=rs.join("");//将书组数据分隔符设为换行符
if(textv.length==0){
resultuser="";
}

document.getElementById("p").innerHTML="<tablewidth='150px'cellpadding='0'bgcolor='#FFFFFF'cellspacing='0'>"+resultuser+"</table>";//将数据打印到指定区域
}

functiongetSelect(obj,objtext){
varol=obj.length;
varres;
obj=objtext.substring(0,ol);
res="<b>"+obj+"</b>"+objtext.substring(ol,objtext.length);
returnres;
}

functionalterBg(j,i){//改变下拉列表鼠标事件颜色
varo=document.getElementById('al'+j);
if(i==0)
o.style.backgroundColor="#FFFFEE";
elseif(i==1)
o.style.backgroundColor="#eeeeee";
}

functiononV(j){//取得下拉列表点击值
varo=document.getElementById('al'+j).innerHTML;
o=o.replace("<B>","");
o=o.replace("</B>","");
document.getElementById('drop').value=o;
}

functionqueryWord(para,str){//该函数为根据条件查询的结果
varr;
r=str.search(para);
if(r==0){
returnstr;
}else{
return"";
}

}

functionSearch(textv,str){//测试用函数在本例中不使用
//vartextv=document.getElementById("drop").value;

varr,result;//声明变量。
r=str.search(textv);//查找字符串。
str=str.slice(r,-1);
document.getElementById("p").innerHTML=str.substring(0,str.indexOf(""));
result=str.substring(0,str.indexOf(""));
returnresult;
//返回Boolean结果。
}

vari=0;
vark;
functionchangeTable(){
varselectLength;
selectLength=document.getElementsByName("tv").length;
document.getElementById("opp").innerHTML=selectLength;

varkeyvalue=event.keyCode;
if(selectLength>0){

if(keyvalue==40){
k=i;
i++;
}
elseif(keyvalue==38){
k=i;
i--
};
if(i<0){
i=selectLength-1;
}elseif(i>selectLength-1){
i=0;
}

varm="al"+i;
varn="al"+k;
if(selectLength==1){
varp=document.getElementById(m);
p.style.backgroundColor="#ffffee";
}else{
if(i>=0&&i<selectLength){
varp=document.getElementById(m);
p.style.backgroundColor="#ffffee";
}

if(k>=0&&k<selectLength){
varh=document.getElementById(n);
h.style.backgroundColor="#eeeeee";
}
if(keyvalue==13){
onV(i);
}
}
}
}

functionloadDiv(){
div1.style.visibility="show";
div2.style.visibility="show";
}
functionshowBody(){
vardiv1=document.getElementById('Layer1');
vardiv2=document.getElementById('Layer2');
div1.style.visibility="hidden";
div2.style.visibility="hidden";

}
</script>

<body>
<divid="opp"></div>
<divid="Layer1"style="position:absolute;background-color:#000000;left:0px;top:0px;width:100%;height:650px;filter:alpha(opacity=20);z-index:1;visibility:hidden;"></div>
<divid="Layer2"style="position:absolute;left:0px;top:150px;width:100%;height:200px;z-index:2;visibility:hidden;">
<tablealign="center"width="50%"height="70"cellpadding="0"bgcolor="#FFFFFF"cellspacing="0">
<tr>
<tdalign="center"><ahref="javascript:void(0)"onclick="showBody()">点击这里formydearGee_gee</a>(Moontoucher'sUImanager)</td>
</tr>
</table></div><br>
<br>
<br>
<br>
<br>

<inputname="drop"type="text"id="drop"onKeyup="droplist();changeTable()">
仿163输入邮件地址自动显示下拉列表(献给最亲爱的gee_gee)
<divid="p"style="height:100px;width:170px;overflow:auto;border-width:1px;border-color:#000000"></div>
<inputtype="hidden"id="hv"name="hv"value="123">
<inputtype="hidden"id="hv"name="hv"value="uio">
<inputtype="hidden"id="hv"name="hv"value="lkjl">
<inputtype="hidden"id="hv"name="hv"value="9876">
<inputtype="hidden"id="hv"name="hv"value="123467">
<inputtype="hidden"id="hv"name="hv"value="fghj">
<inputtype="hidden"id="hv"name="hv"value="yutf78">
<inputtype="hidden"id="hv"name="hv"value="王旺">
<inputtype="hidden"id="hv"name="hv"value="cuiliyi">
<inputtype="hidden"id="hv"name="hv"value="呵呵">
<inputtype="hidden"id="hv"name="hv"value="王子复仇记">
<inputtype="hidden"id="hv"name="hv"value="certerly">
<inputtype="hidden"id="hv"name="hv"value="123">
<inputtype="hidden"id="hv"name="hv"value="uio">

</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics