Recently I have been working on a project that involves an autocomplete functionality as seen in such sites as
Google's Suggest. I like the way Google handles their autocomplete, but I am not sure I understand why they group their suggested entries like they do. For example, if we goto
Google Suggest and type in the letter "a" into the suggestion textbox, ten entries appear showing their search term and their number of results. I am guessing the number of results is how many pages could be returned for this search. The order in which the suggested entries are listed is not in alphabetical, nor is it sorted by the number of possible return pages. It must be sorted on a history of searches for each item. I am trying to mimic this suggestion and autocomplete feature.
It is frustrating writing javascript for IE and Netscape browsers. IE has features which make some tasks extremely easy, but then Netscape browsers will not, and vice versa. The first of these is IE's "OnPropertyChange" event. For an INPUT element, this event handler is great, but it is not compatible with Netscape. So, my solution uses the "OnKeyUp" event of the INPUT element to determine when a user is typing in the control. At this point I then determine the proper key codes and process from there based on my browser. The second case is Netscape's "setSelectionRange" function for an INPUT element. This is perfect for highlighting text, but IE does not have an easy feature similar to this. Instead I need to create a text range, and use "moveStart," "moveEnd," and "select" to achieve something similar. It would be so much easier if there were a standard all web browsers must share. It gives me a headache dealing with different browsers.