Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autofill navigation

Status
Not open for further replies.

subquark

Programmer
Jun 7, 2002
2
US
I would like to make a "browser glossary" where as you type letters, a list of words (ie, movie clip) moves to reflect the letters typed. Like a search feature in a help menu. So if you type "b", the list jumps to b, and "bo" would adjust the list to show words with a beginning of "bo". I do not know of I can use keyUp to look at each letter typed or a myString array.

I would also like it if the word was completely typed out, a "go" button would grab the string and compare it to values in the list. Just like a regular search menu in a help dialog.

Any suggestions would be great! Thanks
 
What about this ... the input field creates a string as it is typed - so, using the onClipEvent(keyDown), compare each letter to an array of known commands (possible 26 arrays ... one for each letter - that might speed things up), and display the first matching item. So for "m", you could just show "_root.inputString" matching to "mArray[0]", since "m" will turn up the first entry in the "m" array. If the user then proceeded to "ma", you would check the input string to "mArray[0].subStr(0, _root.inputString.length)" ... and match the first 2 letters. You'd have to put this in an incremental loop:
Code:
function matchString(arrayName){
    for (i=0; i <= arrayName.length; i++){
        if (arrayName[i].subStr(0, _root.inputString.length) == _root.inputString){
            match = arrayName[i];
            return match;
        }else if (i == arrayName.length){
            match = &quot;No match found&quot;;
            return match;
        }
    }
}
(The use of the arrayName parameter might need checked ... not sure if it will work like that). Of course you have put some error handlers in place ... things like making sure no more key presses are accepted until the search has returned, and you'll have to display the matched word with the letters added already highlighted, so that if the use continues to type the &quot;added&quot; bit of the word is replaced with the next desired letter (that one's a great trick - if you need it post your email and I'll send you the code!).

This is a great project ... very challenging. Hope all goes well, and that this was of some use!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top