prevent dropdown with previous input

G

groups2

When you press the down key while in an input field the default
behavior for some event creates a dropdown of the previously input
text.
What event creates that behavior and how do I stop it ?

For example, to prevent ANY type of default behavior when clicking ANY
key, I thought this would work, but the dropdown still occurs. What am
I doing wrong ?

In html file:<body onload="registersearch()" >
Search Text: <input type='text' id='searchtext' />

in javascript file:
function blank(){
return false;
}
function registersearch(){

document.getElementById("searchtext").onkeyup=blank;
document.getElementById("searchtext").onkeypress=blank;
document.getElementById("searchtext").onkeydown= blank;
document.getElementById("searchtext").onclick=blank;

}
 
P

Peter Michaux

When you press the down key while in an input field the default
behavior for some event creates a dropdown of the previously input
text.
What event creates that behavior and how do I stop it ?

This is a browser feature. Presumably the user chose the browser
because the browser's features are appealing. Yes some of these
browser features are aggravating at times. It isn't really a good idea
to be trying to change how the browser works. I don't know if you can
even have any affect on this situation.

Peter
 
R

Randy Webb

Peter Michaux said the following on 6/17/2007 5:23 PM:
This is a browser feature. Presumably the user chose the browser
because the browser's features are appealing. Yes some of these
browser features are aggravating at times. It isn't really a good idea
to be trying to change how the browser works. I don't know if you can
even have any affect on this situation.

It is an auto-fill feature and no, you can't have any effect on it's
behavior.
 
G

groups2

Peter Michaux said the following on 6/17/2007 5:23 PM:



It is an auto-fill feature and no, you can't have any effect on it's
behavior.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

Ok thanks. I found out I can trick the autocomplete into not appearing
by having a start value of ' '. The autocomplete doesn't seem to work
at all if the first letter is a blank, even if previous searches
started with a blank. After that it will only appear if the user
deletes everything in the field, which doesn't usually happen, so it
effectively solves the problem.

The input field is for text to search for in an associated drop down,
to make it easier to find the right item in the dropdown. As each
letter is entered the selection moves to the correct choice in the
dropdown. In other words, it acts like autocomplete but instead of
adding the finished text to the input field, it hilights the finished
text in the dropdown. The default autocomplete just gets in the way.
I just have to make sure the search for the right item can work even
if the first letter is a blank, plus it must ignore the blank. But all
that was easy because all the search does is check to see where the
text lands alphabetically in the select list, and this automatically
ignores the spaces. In other words, " ABC" is effectively the same as
"ABC"

This is not for web customers, it is for people who spend all day on
the page filling phone orders. I'm trying to eliminate as many
keystrokes as possible, and the autocomplete takes an extra mouse
click to get rid of it.
 

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
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top