Autocomplete in dropdown on ASP

A

Abe Hills

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.
 
R

Randy R

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).
 
B

Bob Barrows

Abe said:
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
 
J

Jeff Cochran

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)
(e-mail address removed) - 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/
====================================
 
D

Dan Williams

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top