I have an Array('abcdef','bcdefa','cdefab','defabc').
I key in keywords 'def' and I would like it to show the first text first, then show the items which match the keywords. In this case:
defabc
abcdef
bcdefa
cdefab
I tried by using OR for the RegExp, like:
var re = new RegExp("^" + t + "|" + t, "i");
But it doesn't work. Could I solve this by just changing the regular expression? If not, how could I modify the javascript file to make this to work?
I found a little bug. As mentioned before, the script doesn't work for multiple instances. This is because the array with the values is a global variable instead of a local one.
"this.actb_keywords = new Array();" should be "var actb_keywords = new Array();"
and all "actb_self.actb_keywords" should be "actb_keywords"
it works fine,but the problem whenever i type a word.. and then press enter it automatically takes the closest autosugessted word from the list ...for example
1.the list contains the word "an apple"..so when ever i type "app" in the textbox and then press enter ..it takes the word "an apple" from the autosugessted list .
example 2..if i type "king"..and then press enter it automatically takes "kingbird"..
hence can any one solve it ?
actually i am looking for this solution :
it should only take the word from autosugesstion list if selected from arrow key or mouse
other wise it should take word from textbox which is typed by user
I downloaded your Auto-complete code sample from "http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=8020&av=41368" to implement an on-line translator. I would like to know how to implement auto-complete control with external js file?
Within function actb_checkkey(), the switch() statement checks for the Up, Down, Enter and Tab keys. If you add one more case statement, you can allow the user to hide/cancel the displaying list:
If this is added before the final default:, no other code is needed, and you can start typing your text in the autocomplete form, hit ESC, and the suggestion box disappears.
One suggested given for this code is to create a new instance of actb(). If you want to modify the array after it has been saved, be sure to capture the returned object:
var customarray_description = new Array();
var obj_description_school = new actb(document.getElementById('school'), customarray_description);
var customarray_code = new Array();
var obj_code_school = new actb(document.getElementById('school'), customarray_code);
obj_description_school.actb_keywords = a_different_customarray_description;
...