Autocomplete in dropdown on ASP

Discussion in 'ASP General' started by Abe Hills, Jul 16, 2003.

  1. Abe Hills

    Abe Hills Guest

    I'm trying to put a drop-down box on an asp, which will containing a list of
    names.

    When a user starts typing a name that is in the list I want the text to
    autocomplete

    e.g. when the user types 'st' I'd like the text to autocomplete to steve or
    stephen, depending on which is first in the list.

    Can this be done??

    Thanks in advance.
    Abe Hills, Jul 16, 2003
    #1
    1. Advertising

  2. Abe Hills

    Randy R Guest

    > When a user starts typing a name that is in the list I want the text to
    > autocomplete


    This is a client-side issue... I believe users can disable and enable this
    within their browser settings. If there's a way to enable it from within
    the page, then it's more than likely done with client-side javascript. I'd
    look into a javascript group (comp.lang.javascript).
    Randy R, Jul 16, 2003
    #2
    1. Advertising

  3. Abe Hills

    Bob Barrows Guest

    Abe Hills wrote:
    > I'm trying to put a drop-down box on an asp, which will containing a
    > list of names.
    >
    > When a user starts typing a name that is in the list I want the text
    > to autocomplete
    >
    > e.g. when the user types 'st' I'd like the text to autocomplete to
    > steve or stephen, depending on which is first in the list.
    >
    > Can this be done??
    >
    > Thanks in advance.


    It can't be done via ASP, but it can with client-side code. Go to
    http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp and
    download my dynamic listbox example. Even if you can't use this specific
    code in your environment to accomplish your task, you may get some ideas
    about how to do it from my code.

    Please follow up on a client-side scripting newsgroup such as
    microsoft.public.scripting.vbscript (or jscript) or one of the groups whose
    name include "dhtml".

    HTH,
    Bob Barrows
    Bob Barrows, Jul 16, 2003
    #3
  4. Abe Hills

    Jeff Cochran Guest

    On Wed, 16 Jul 2003 09:29:27 +0100, "Abe Hills"
    <> wrote:

    >I'm trying to put a drop-down box on an asp, which will containing a list of
    >names.
    >
    >When a user starts typing a name that is in the list I want the text to
    >autocomplete
    >
    >e.g. when the user types 'st' I'd like the text to autocomplete to steve or
    >stephen, depending on which is first in the list.
    >
    >Can this be done??


    Not in ASP, since it's client side, but I think Curt had some code on
    darkfalz.com that did this. Hang on...

    Dum de dum... deedle doo...

    Yup. Here's a link:

    http://www.darkfalz.com/VBNotes/postdetails.aspx?pstID=1086

    Jeff
    ===================================
    Jeff Cochran (IIS MVP)
    - Munged of Course

    I don't get much time to respond to direct email,
    so posts here will have a better chance of getting
    an answer. Besides, everyone benefits here.

    Suggested resources:
    http://www.iisfaq.com/
    http://www.iisanswers.com/
    http://www.iistoolshed.com/
    http://securityadmin.info/
    http://www.aspfaq.com/
    http://support.microsoft.com/
    ====================================
    Jeff Cochran, Jul 16, 2003
    #4
  5. Abe Hills

    Dan Williams Guest

    Try this code:-

    <html>
    <head>

    <Script language="javascript">
    </Script>

    <SCRIPT LANGUAGE=vbscript>
    <!--
    dim staffBuf

    function SelectStaff
    dim objSelect, i, iLen
    SelectStaff = False
    staffBuf = staffBuf & Chr(window.event.keyCode)
    iLen = len(staffBuf)
    set objSelect = document.form1.FilterStaff
    for i = 0 to objSelect.Options.length - 1
    if strcomp(left(objSelect.Options(i).Text, iLen), staffBuf, 1) = 0
    then
    objSelect.SelectedIndex = i
    exit function
    end if
    next
    staffBuf = ""
    end function
    -->
    </script>

    <body onload="form1.FilterStaff.focus()">
    <form name="form1">
    <select name="FilterStaff" onKeyPress="return SelectStaff();">
    <option value="AAA">AAA</option>
    <option value="ABB">ABB</option>
    <option value="ABC">ABC</option>
    <option value="BAA">BAA</option>
    <option value="BBA">BBA</option>
    <option value="BBC">BBC</option>
    <option value="CAA">CAA</option>
    <option value="CAB">CAB</option>
    <option value="CBB">CBB</option>
    </select>
    </form>
    </body>
    </html>

    Not sure why, but it doesn't seem to like it if you take out the first
    Javascript section. Probably something to do with the return statement.

    Dan


    "Abe Hills" <> wrote in message
    news:228Ra.9081$...
    > I'm trying to put a drop-down box on an asp, which will containing a list

    of
    > names.
    >
    > When a user starts typing a name that is in the list I want the text to
    > autocomplete
    >
    > e.g. when the user types 'st' I'd like the text to autocomplete to steve

    or
    > stephen, depending on which is first in the list.
    >
    > Can this be done??
    >
    > Thanks in advance.
    >
    >
    Dan Williams, Jul 16, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey
    Replies:
    5
    Views:
    17,412
    PeterBrunone
    Sep 6, 2006
  2. Replies:
    1
    Views:
    657
    Mark Fitzpatrick
    Jan 17, 2007
  3. Therasa
    Replies:
    3
    Views:
    544
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 13, 2007
  4. AutoComplete in ASP:TextBox control in ASP.NET 1.1

    , Jan 17, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    258
    Mark Fitzpatrick
    Jan 17, 2007
  5. Replies:
    1
    Views:
    147
    Mark Fitzpatrick
    Jan 17, 2007
Loading...

Share This Page