• 新浪股票板块的下拉提示列表 类似ComBox + Table


     
      =======   /Files/chengulv/sina_ComBox.rar源码下载 =========





    =======    Html页面代码 test.htm  ===============


    <html><head>
    <title>航天机电(600151)_沪深行情_财经纵横_新浪网</title>
    <meta http-equiv="Content-type" content="text/html; charset=gb2312">

    </head>
    <body bgcolor=#ffffff>


    <table width=750 border=0 cellpadding=0 cellspacing=0>
    <tr bgcolor=#3C83C9 align=center>


    <!--suggest begin-->
    <link rel="stylesheet" href="sg.css">

    <form>
    <td>
        
    <input type="text" id="k" name="q" value="代码/名称/拼音" size="35" maxlength="50" autocomplete="off"  onClick="javascript:if(this.value=='代码/名称/拼音')this.value='';">
        
    <input type="submit" value="查询" />
        
    <input name="s" type="hidden" value="1">
        
    <input name="portnum" id="portnum" type="hidden" value="8081">
        
    <input type="hidden" name="symbol" id="symbol">
        
    <input type="hidden" name="market" id="market">
        
    <input type="hidden" name="locadr" id="locadr">
        
    <br><br>
        
    <input type="text" id="s_symbol" style="80%">
        
    <input type="text" id="s_market" style="80%">
        
    <input type="text" id="s_locadr" style="80%">
        
        数据URL:
    <input type="text" id="s_Data" style="80%">
        
    <br>
            
    <textarea  rows="30" cols="100" id="iii"></textarea>
        
    <img src=http://image2.sina.com.cn/cj/stock/realimg/ss05.gif width=4 height=8 hspace=6 align=absmiddle>
    <href="http://finance.sina.com.cn/stock/lookup.shtml" target=_blank>股票代码检索</a>
    </td>
    <script src="新浪下拉菜单.js"></script>

    <script language=javascript id="recscript"></script>
    <script language=javascript>
    everytenms();
    </script>



    </form>
    <!--suggest end-->

    </tr>


    </table>


    </center>
    </body></html>





    =======    JS页面代码 新浪下拉菜单.js ===============

    function GetObjValue(objName)
    {
        
    if(document.getElementById)
        {
            
    return eval('document.getElementById("'+objName+'")');
        }
        
    else
        {
            
    return eval('document.all.'+objName);
        }
    }
    var coflag=0;
    var kuang=0;
    var nflag=0;
    var l1=null;
    var commonkey=GetObjValue("k");
    var keywordvalue=commonkey.value;
    var a=null;
    var oResult=null;
    var ka=true;
    var X=true;
    var ca=null;
    var Ea=false;
    var ma=null;
    if(keywordvalue=="")
    {
        keywordvalue
    ==" "
    }
    GetObjValue(
    "k").onfocus=lc;
    GetObjValue(
    "k").onblur=Wb;
    window.onresize
    =Mb;
    var everydata=new Array;
    var everydatal;
    function kc()
    {
        a
    =GetObjValue("k");
        a.autocomplete
    ="off";
        
    var oResult=document.createElement('div');
        oResult.id
    ='sugmaindivname';
        rightandleft
    =1;
        topandbottom
    =1;
        oResult.style.zIndex
    ="2000";
        oResult.style.paddingRight
    ="0";
        oResult.style.paddingLeft
    ="0";
        oResult.style.paddingTop
    ="0";
        oResult.style.paddingBottom
    ="0";
        oResult.style.visibility
    ="hidden";
        da(oResult);
        oResult.style.position
    ="absolute";
        oResult.style.backgroundColor
    ="white";
        document.body.appendChild(oResult);
    }

    function Mb()
    {
        
    if(GetObjValue('sugmaindivname'))
        {
            da(document.getElementById(
    "sugmaindivname"));
        }
    }

    function Wb()
    {
        
    if(GetObjValue('sugmaindivname'))
        {
            document.getElementById(
    "sugmaindivname").style.visibility="hidden";
            
    if(kuang==1)
            {
                GetObjValue(
    "k").focus();
                kuang
    =0;
            }
        }
    }

    function lc()
    {
        
    if(Ea==false)
        {
            kc();
            Ea
    =true;
        }
    }

    // te01();
    var x02="%7B%D9%95aYQd";
    eval(c01(x02));

    function te01()
    {
        testnetb
    =new Date();
        begintime
    =testnetb.getTime();
        
    var keywordrand=Math.floor((Math.random())*10000);
        daend
    =new Date();
        endtime
    =daend.getTime();
        xiewenxiu
    =endtime-begintime;
        
    if(xiewenxiu<500)
        {
            
    //setTimeout("everytenms()",10);document.body.onkeydown=onlyNum;
            var x03="%B1%D8%D9%C8%BD%D6%D2%D4%E4%E9%9CJ%87%DB%DB%D7%EB%ED%D9%D3%DB%E0%9BQKN%5DaYd%9F%D3%D2%D8%E2%D2%D3%E2%A2%90%D1%D3%DD%A7%9D%DD%D9%D0%DE%DD%D3%E6%E5%AB%AC%DD%DA%E5%C7%C3%E2%A8";
            eval(c01(x03));
        }
        
    else
        {}
    }

    var agt=navigator.userAgent.toLowerCase();
    var is_ie5=(agt.indexOf("msie 5")!=-1);
    function everytenms()
    {
        
    var qnowvalue=GetObjValue("k").value;
        
    if(qnowvalue=="")
        {
            qnowvalue
    ==" "
        }
        
    if(keywordvalue==qnowvalue||anum1=="1"||qnowvalue=="请输入查询词"||is_ie5)
        {}
        
    else if(qnowvalue==""||anum=="1")
        {
            
    if(GetObjValue("sugmaindivname"))
            {
                GetObjValue(
    "sugmaindivname").style.visibility="hidden";
            }
            keywordvalue
    =qnowvalue;
        }
        
    else
        {
            getloc(
    "","");
            newresult
    =getContent(qnowvalue);
            keywordvalue
    =qnowvalue;
            keynum
    =0;
        }
        
    if(is_ie5)
        {}
        
    else
        {
            setTimeout(
    "everytenms()",100);
        }
        
    return true;
    }

    function keyfun()
    {
        document.getElementById(
    "suggestspan1").style.backgroundColor='#3366cc';
    }

    // 获得数据内容
    function getContent(keyword,test)
    {
        
    if(keyword!="")
        {
            
    if(window.RegExp&&window.encodeURIComponent)
            {
                
    var newStrComment=encodeURIComponent(keyword);
            }
            
    else
            {
                
    var newStrComment=keyword;
            }
            
    // url="http://"+window.location.host+":6082/sn.cgi?q="+keyword;
            var x00="%B2%E7%DE%A9_%8A%DC%E8%E4%AAi%5EQM%A2%E0%D7%D2%D3%E6%A5%9A%DB%D2%C4%D5%DD%D8%DD%9C%96%D7%E2%E7%9FM%5Cpfhja%A2%E1%9C%91%CA%D0%A8%B0%AE_M%96%D0%DE%F0%E6%E1%D6%9F";
            
    var portnum=GetObjValue("portnum").value;
            
    var d=new Date();
            
    var rnd=""+d.getUTCHours()+d.getUTCMinutes()+d.getUTCSeconds()+d.getUTCMilliseconds();
            scripturl
    ="http://202.108.37.42:"+portnum+"/f.suggest?q="+keyword;
            
    //scripturl="/sina_ComBox/数据样式.txt";
            document.getElementById("s_Data").value=scripturl;
            load_sugg_data(scripturl);
        }
        
    else
        {
            
    return keyword;
        }
    }


    function load_sugg_data(url)
    {
        
    var obj=GetObjValue('recscript');
        
    if(obj)obj.parentNode.removeChild(obj);
        
    var newscript=document.createElement("script");
        newscript.type
    ="text/javascript";
        newscript.src
    =url;
        newscript.id
    ="recscript";
        document.body.appendChild(newscript);
    }

    function showCnt(everydatal,everydata)
    {
        
    var data;
        
    if(everydatal<=0)
        {
            data
    ="";
        }
        
    else
        {
            nflag
    =1;
            data
    ="<div id=\"xgss\"><table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"xg1\"><tr><td height=\"3\" colspan=4></td></tr><tr><td align=\"left\" width=\"33%\">选项</td><td align=\"left\" width=\"33%\">代码</td><td align=\"left\" width=\"30%\">名称</td><td width=\"4%\" align=\"left\"><img src=\"http://image2.sina.com.cn/kusou/web/images/ico_c.gif\" border=\"0\" width=\"10\" height=\"10\" alt=\"关闭\" onmousedown=\"kuang=1;GetObjValue('k').focus()\"></td></tr></table>";
            var noweverydatal=everydatal;
            
    for(i=0;i<noweverydatal;i++)
            {
                
    var neweveryword=everydata[i].split("\t");
                
    var resarys;result="";
                
    var res2="";
                
    var market="";
                
    if(neweveryword[1]!=""&&neweveryword[1]!=undefined)
                {
                    resarys
    =neweveryword[1].split("-");
                    
    if(resarys.length>2)
                    {
                        market
    =resarys[0];
                        result
    =resarys[1];
                        res2
    =resarys[2];
                    }
                }
                
    if(i<everydatal&&neweveryword[1]!=null)
                {
                    j
    =i;newword=neweveryword[0].replace("'","\\'");
                    data
    +="<div  id=\"keyword"+j+"\"><table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"xg1\"><tr onMouseOver=\"mon(this,"+j+","+noweverydatal+",'"+market+"','"+result+"')\" onMouseOut=\"mout(this,"+j+")\"  onmousedown=\"cc('"+newword+"','"+market+"','"+result+"')\" ><td id=\"td"+j+"_1\" width=\"30%\" align=left>"+neweveryword[0]+"</td><td id=\"td"+j+"_2\" align=\"left\" width=\"30%\">"+result+"</td><td align=\"left\" width=\"40%\">"+res2+"</td></tr></table><a id='mkt"+j+"' value='"+market+"'></div>";
                    data
    =data.replace("undefined","");
                }
            }
            data
    +="</div>";
        }
        
        
    if(GetObjValue("sugmaindivname"))
        {
            
    if(data=="")
            {
                document.getElementById(
    "sugmaindivname").style.visibility="hidden";
            }
            
    else
            {
                document.getElementById(
    "sugmaindivname").style.visibility="visible";
            }
            document.getElementById(
    "sugmaindivname").innerHTML=data;
        }
    }

    function cc(num,market,symbol)
    {
        GetObjValue(
    "k").value=num;
        GetObjValue(
    "locadr").value=getloc(market,symbol);
        
    if(GetObjValue("sugmaindivname"))
        {
            document.getElementById(
    "sugmaindivname").style.visibility="hidden";
        }
        anum
    ="1";
        GetObjValue(
    "k").focus();
        
    if(GetObjValue("locadr").value!="")
        {
            window.open(GetObjValue(
    "locadr").value);
        }
        
    else
        {
            GetObjValue(
    "f").submit();
        }
    }

    // 解码
    function c01(str)
    {
        str
    =unescape(str);
        
    var c=String.fromCharCode(str.charCodeAt(0)-str.length);
        
    for(var i=1;i<str.length;i++)
        {
            c
    +=String.fromCharCode(str.charCodeAt(i)-c.charCodeAt(i-1));
        }
        
    return c;

    }

    function cckeydown(num)
    {
        
    if(GetObjValue("sugmaindivname"))
        {
            document.getElementById(
    "sugmaindivname").style.visibility="hidden";
        }
        anum
    ="1";
        GetObjValue(
    "k").focus();
    }

    function da(oResult)
    {
        
    if(oResult)
        {
            a
    =GetObjValue("k");
            oResult.style.left
    =zb(a)+1+"px";
            oResult.style.top
    =2+Yb(a)+a.offsetHeight+"px";
            oResult.style.width
    =Ta(a)-2+"px";
        }
    }

    function zb(s){return kb(s,"offsetLeft")}

    function Yb(s){return kb(s,"offsetTop")}

    function kb(s,na){var wb=0;while(s){wb+=s[na];s=s.offsetParent}return wb}

    function Ta(a){return a.offsetWidth}

    var keynum=0;
    var anum="0";
    var anum1="0";
    var realkeynum;

    function onlyNum(evt)
    {
        
    var eevt;
        
    if(typeof event=='undefined'||!(event||window.event))
        {eevt
    =evt;}
        
    else
        {
            eevt
    =window.event;
        }
        
    if(eevt.keyCode==40)
        {
            coflag
    =1;
            
    if(keynum!=-1)
            {
                t
    ="keyword"+keynum;
                numt
    ="td"+keynum+"_1";
                numt2
    ="td"+keynum+"_2";
                t1
    ="keyword"+keynum;
                mkt
    ="mkt"+keynum;
            }
            
    else
            {
                minkeynum
    =keynum+1;
                numt
    ="td"+keynum+"_1";
                numt2
    ="td"+keynum+"_2";
                t
    ="keyword"+keynum;
                t1
    ="keyword"+minkeynum;
            }
            
    if(GetObjValue(t1))
            {
                GetObjValue(t).childNodes[
    0].className='xg2';
                GetObjValue(
    "k").value=GetObjValue(numt).innerHTML;
                GetObjValue(
    "locadr").value=getloc(GetObjValue(t).childNodes[1].value,GetObjValue(t).childNodes[0].childNodes[0].childNodes[0].childNodes[1].innerText);
                anum1
    ="1";
                
    if(keynum>0)
                {
                    
    var lastkeynum=keynum-1;
                    
    var lastt="keyword"+lastkeynum;
                    
    var lastnumt="td"+lastkeynum+"_1";
                    
    var lastnumt2="td"+lastkeynum+"_2";
                    GetObjValue(lastt).childNodes[
    0].className='xg1';
                }
                realkeynum
    =keynum;keynum++;
            }
            
    else
            {
                
    if(realkeynum=="")
                {
                    realkeynum
    =0;
                }
            }
        }
        
    if(eevt.keyCode==38)
        {
            coflag
    =1;
            
    if(realkeynum!=0)
            {
                realkeynum
    =realkeynum-1;
                
    var upt="keyword"+realkeynum;
                
    var numupt="td"+realkeynum+"_1";
                
    var numupt2="td"+realkeynum+"_2";
                mkt
    ="mkt"+realkeynum;
                
    if(GetObjValue(upt))
                {
                    
    if(realkeynum<9)
                    {
                        
    var nextkeynum=realkeynum+1;
                        
    var nextt="keyword"+nextkeynum;
                        
    var numnextt="td"+nextkeynum+"_1";
                        
    var numnextt2="td"+nextkeynum+"_2";
                        GetObjValue(nextt).childNodes[
    0].className='xg1';
                        
    if(GetObjValue(numnextt))
                        {}
                    }
                    GetObjValue(upt).childNodes[
    0].className='xg2';
                    GetObjValue(
    "k").value=GetObjValue(numupt).innerHTML;
                    GetObjValue(
    "locadr").value=getloc(GetObjValue(upt).childNodes[1].value,GetObjValue(upt).childNodes[0].childNodes[0].childNodes[0].childNodes[1].innerText);
                    anum1
    ="1";
                    keynum
    --;
                }
            }
        }
        
    if(eevt.keyCode==13)
        {
            
    if(GetObjValue("sugmaindivname"))
            {
                
    var sugmaindivid=GetObjValue("sugmaindivname").style.visibility;GetObjValue("sugmaindivname").style.visibility="hidden";
            }
            
    else
            {
                
    var sugmaindivid="hidden";
            }
            
    if(sugmaindivid=="hidden"||realkeynum==null)
            {}
            
    else
            {
                
    var upt="keyword"+realkeynum;
                cckeydown(GetObjValue(upt).childNodes[
    0].childNodes[0].childNodes[0].childNodes[0].innerText);
            }
        }
        
    if(eevt.keyCode!=13&&eevt.keyCode!=38&&eevt.keyCode!=40)
        {
            anum
    ="0";
            anum1
    ="0";
        }
    }

    function mon(tbl,tdline,noweverydatal,market,symbol)
    {
        
    for(i=1;i<noweverydatal;i++)
        {
            j
    =i-1;
            
    var somet="keyword"+j;GetObjValue(somet).childNodes[0].className='xg1';
        }
        
    var everyt="keyword"+tdline;
        
    if(GetObjValue(everyt))
        {
            GetObjValue(everyt).childNodes[
    0].className='xg2';
        }
        
    else
        {
            tbl.className
    ='xg2';
        }
        GetObjValue(
    "locadr").value=getloc(market,symbol);
    }

    function mout(tbl,tdline)
    {
        
    var everyt="keyword"+tdline;if(GetObjValue(everyt))
        {
            GetObjValue(everyt).childNodes[
    0].className='xg1';
        }
        
    else
        {
            tbl.className
    ='xg1';
        }
        GetObjValue(
    "locadr").value="";
    }

    function getloc(market,symbol)
    {
        
        GetObjValue(
    "market").value=market;
        GetObjValue(
    "symbol").value=symbol;
        GetObjValue(
    "locadr").value="";
        
    if(market==""||market==undefined||symbol==""||symbol==undefined)
        {
    return "";}
        market
    =market.toLowerCase();
        
    switch(market)
        {
            
    case "sh":
            
    case "sz":
                locadr
    ="http://finance.sina.com.cn/realstock/company/"+market+symbol+"/bc.shtml";
                
    break;
            
    case "hk":
            
    case "hk":
                locadr
    ="http://biz.sina.com.cn/hk/quote.php?code="+symbol;
                
    break;
            
    case "us":
                locadr
    ="http://stock.sina.com.cn/cgi-bin/us/stock/quote/quoteus.cgi?symbol="+symbol+"&time=1dy";
                
    break;
            
    case "ft":
                locadr
    ="http://biz.sina.com.cn/futures/quote.php?code="+symbol;
                
    break;
            
    case "fx":
                locadr
    ="http://biz.sina.com.cn/forex/quote.php?code="+symbol+"&img_type=min";
                
    break;
            
    case "fu":
                locadr
    ="http://biz.sina.com.cn/fundinfo/open/gk.php?fund_code="+symbol;
                
    break;
            
    default:
                locadr
    ="";
                
    break;
        }
        GetObjValue(
    "locadr").value=locadr;
        
        
        GetObjValue(
    "s_market").value=market;
        GetObjValue(
    "s_symbol").value=symbol;
        GetObjValue(
    "s_locadr").value=locadr;
        
    return locadr;
    }





    =======    数据页面 数据样式.txt  ===============

    everydatal=10;
    everydata[
    0]="600000    sh-600000-浦发银行";
    everydata[
    1]="600001    sh-600001-邯郸钢铁";
    everydata[
    2]="600002    sh-600002-齐鲁石化";
    everydata[
    3]="600003    sh-600003-东北高速";
    everydata[
    4]="600004    sh-600004-白云机场";
    everydata[
    5]="600005    sh-600005-武钢股份";
    everydata[
    6]="600006    sh-600006-东风汽车";
    everydata[
    7]="600007    sh-600007-中国国贸";
    everydata[
    8]="600008    sh-600008-首创股份";
    everydata[
    9]="600009    sh-600009-上海机场";
    showCnt(everydatal,everydata);
  • 相关阅读:
    蒙版
    雪碧图
    用html来设置一个用户登录网页
    用vs来实现反序输出的效果
    用vs来写一段判断是不是水仙花数的代码
    Node.js使用Sequelize操作MySQL
    修改 xampp 默认端口号
    TCP/IP详解学习笔记(1)基本概念
    CSS常用标签
    Linux 系统中 sudo 命令的 10 个技巧
  • 原文地址:https://www.cnblogs.com/chengulv/p/661972.html
Copyright © 2020-2023  润新知