对于每个选项都有一个对应的ID,当选择某一项,应该能读它的ID.

解决方案 »

  1.   

    你这些数据是数据库的?
    如果是就用AJAX读取后台返回给前台
      

  2.   

    是不是就像Google的下拉列表一样?我也曾经模仿过
    下拉列表的数据需要用Ajax来动态获取,由textbox的onchange时间触发
    只要好不好看,当然要靠HTML和CSS咯
      

  3.   

    a<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <style>
    <!--
    body{font-size:12px;}
    #show{border:1px solid #9abcde; line-height:23px; width:200px; margin:0px;}
    #show li{list-style:none;}
    #sug{margin:0px auto;}
    .style1 {font-size: x-large}
    -->
    </style>
    <script language="javascript">
    <!--
    var xmlHttp = false;
    function ajaxcreate(){
    try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e2) {
    xmlHttp = false;
    }
    }
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
    }
    if(!xmlHttp){alert('Create Xmlhttp Fail ');return false;}
    }
    function sugguest(){
    ajaxcreate();
    var xmvalue=document.getElementById("key").value;
    //var url="post.ASP?key="+encodeURI(xmvalue)+"&rnd="+Math.random();
    var url="post.ASP?key="+(xmvalue)+"&rnd="+Math.random(1);
    if (xmvalue== null || xmvalue.length>20 || xmvalue == "") return false;
    xmlHttp.open("POST",url,true);
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlHttp.send(xmvalue);
    xmlHttp.onreadystatechange=returnstate;
    }
    function returnstate(){
    if(xmlHttp.readyState != 4 ){
    document.getElementById("sug").innerHTML="plase wait....";
    }
    if(xmlHttp.readyState == 4 ){
    document.getElementById("sug").innerHTML=xmlHttp.responseText;
    }
    }function fillin(str){
    document.getElementById('key').value=str;
    obj =document.getElementById('sug');
    obj.innerHTML='';
    obj.style.display='none';
    }
    function other(){
    document.getElementById('sug').style.display='block';
    }function losefouse(){
    setInterval("func()",4000);
    var time=setInterval("func()",1000);
    clearTimeout(time);}function func(){
     ob=document.getElementById('sug');
        ob.style.display = 'none';  
     } -->
    </script>
    <body >
    <table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
      <form name="form1" method="post" action=""><tr>
        <td>
          <input name="key" type="text" id="key" onFocus="other();" onKeyDown="sugguest();"  onBlur="losefouse();"  size="27" autocomplete=off >
          <input type="submit" name="Submit" value="搜索">
        </td>
      </tr></form>
      <tr>
        <td ><div id="sug" onClick="javascript:func();"></div></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>
      

  4.   

    post.ASP:
    <%
    Response.charset="GB2312"
    sjbyDB="sjnews.mdb"
    connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&sjbyDB&"")
    'On Error Resume Next
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open connstr
    If Err Then
    err.Clear
    Set Conn = Nothing
    Response.Write "数据库连接出错,请联系管理员。"'
    Response.End
    End If

    key=Request.QueryString("key")
    set rs = server.CreateObject ("adodb.recordset")
    sql="select  * from news where title like '%"&key&"%' order by id desc"
    rs.open sql,conn,1,1
    response.Write("<div id=show >")
    if not rs.bof then
    do while not rs.eof
    response.Write("<li onMouseOver=""this.style.background='#d7ebff'"" onMouseOut=""this.style.background='#ffffff'"" onclick=""javascript:fillin(this.innerHTML);"">"&rs("title")&"</li>")
    rs.movenext
    loop
    else
    response.Write key
    end if
    response.Write("</div>")
    %>