Disable auto-search in listbox control

B

Ben

I've got an asp page that populates a listbox with info from a db.

The list box ends up being pretty big, so I want to be able to search
it effectively. I like the method wherein the user types the letters
of the word they are looking for from within the listbox and the
control automatically scrolls to the item matching the chars they have
typed thus far.

Example:

If the listbox were to contain states Alabama, Alaska, and Louisiana,
when the user clicked in the listbox and typed "Ala" the box would
scroll to Alabama, and when they typed an additional 's', so the typed
string was "Alas", the box would scroll to Alaska.

Problem:

I've got javascript that does this very well, but the listbox control
default search behavior overrides my javascript. So, the javascript
will correctly index to Alaska when "Alas" is typed, but when the
javascript function is done running, the list moves down to Louisiana,
because the asp control thinks that by typing 'l' the user wants to
move to the first item in the box beginning with an 'l'.

Question:

Can I disable the default search behavior in the control? If so, how?
If not, does anyone have any thoughts on how else I might get around
this problem?

Thanks and regards,

Ben
 
B

Bob Barrows [MVP]

Ben said:
I've got an asp page that populates a listbox with info from a db.

The list box ends up being pretty big, so I want to be able to search
it effectively. I like the method wherein the user types the letters
of the word they are looking for from within the listbox and the
control automatically scrolls to the item matching the chars they have
typed thus far.

Example:

If the listbox were to contain states Alabama, Alaska, and Louisiana,
when the user clicked in the listbox and typed "Ala" the box would
scroll to Alabama, and when they typed an additional 's', so the typed
string was "Alas", the box would scroll to Alaska.

Problem:

I've got javascript that does this very well, but the listbox control
default search behavior overrides my javascript. So, the javascript
will correctly index to Alaska when "Alas" is typed, but when the
javascript function is done running, the list moves down to Louisiana,
because the asp control thinks that by typing 'l' the user wants to
move to the first item in the box beginning with an 'l'.

Question:

Can I disable the default search behavior in the control? If so, how?
If not, does anyone have any thoughts on how else I might get around
this problem?

This is not an asp issue (you would have the same problem if you put the
control on a non-asp page would you not?). Please follow up in a client-side
scripting newsgroup such as one of the ones with "dhtml" and "scripting" in
their names, or the m.p.scripting.jscript newsgroup.

I have created a demo illustrating one way to do this at
http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp&c=&a=clear

Bob Barrows
 
B

Ben

Bob Barrows said:
This is not an asp issue (you would have the same problem if you put the
control on a non-asp page would you not?). Please follow up in a client-side
scripting newsgroup such as one of the ones with "dhtml" and "scripting" in
their names, or the m.p.scripting.jscript newsgroup.

I have created a demo illustrating one way to do this at
http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp&c=&a=clear

Bob Barrows

Thanks for the pointer as well as the example. I'll try some other groups.

Regards,

Ben
 

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

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top