I am running into one small glitch. The autocomplete does not work at all (no errors, no nothing) unless I leave the textbox (it loses focus) and re-enter it again (it re-gains focus). After that, everything works perfectly. Until that happens though, nada -- I can type to my heart's content and nothing happens.
I added in an alert('ca') at the beginning of the actb() function as a debug just to make sure that the onkeypress event is firing the function and that the array of values is being passed in. This test turned out OK at all times, regardless of the focus-related issue above. The core code has not been changed outside of this one-liner debug, which was of course promptly removed. (alert() onkeydown is incredibly irritating by the way).
So the only thing that comes to mind is that the actb() function is somehow focus-dependant in processing the array and sending output... does anyone have any ideas here?
I've just noticed exactly the same thing! I've been hacking at the code (I've got it working in an AJAXy way with a server to support auto-selection from nearly 7000 records: not something you want people to have to download). I'm trying to fix a couple of other bugs at the same time so will report back if I can fix this one.
Right, I now know what's happening, although I'm not certain that my bus is the same as yours!
I was giving the input box focus with an explict call to element.focus() elsewhere in on the page. I found that actb then didn't work until I moved the focus away from this field and back again.
Here's why:
There are two functions - actb_setup() and actb_clear that are called whenever a particular input box gets, or loses, focus, respectively.
Since the box has focus when act starts, the first is never being called. As these functions are the ones that bind key events to the particular actb associated with that input box, without being setup, nothing happens.
Rather than mess around with the code, and risk piling stray event catchers into the system, I just made sure that I called onfocus after I had initialised actb.
Your code has a strange "removed" in it - was that a call to something that this message board removes? If so, I'm guessing that this message will also include lots of mentions of "removed" - I hope it makes sense.
Hello,
if you are interested, I have create a javascript control JSControlTags.Autocomplete control, which use prototype.js
and scriptaculous.js. So with prototype.js, the javascript control
has a good design. JSControlsTags is project which give you JSP taglib
which generate javscript control JSControlTags.Autocomplete.
You can see demo at http://jscontrolstags.sourceforge.net/demo/autocomplete/autocomplete-test1.html
and find project at http://jscontrolstags.sourceforge.net/
I want to add a custom event. When visitor selects an item in the autocomplete list, can be worked javascript like alert('Selected') ?
And one more issue,
There are a green apple, a green car, a blue car in my array. When type car green, i want to list a green car, a blue car. Because i use long strings. And visitors can search like that; car green !
Finally !
I got that very same actb (all the original js is completely untouched)
on a reusable, drag and drop, with designer editor support (also for the possible values) server control.
after all the code is OK i think for being a one day prod.
if u are zic you can contact me on email, so that i can send you a sample
and you may update the ariticle for all those ppl having trouble just because of their experience.
the control is already tested for being more than one as well as nested in other user controls, and also inside a nested master pages structure, worked perfectly.
what u get is a control that you can drag fromt the toolbox
once the object is visible in the designer you can edit the size & colors
visually it's exaclty as a TextBox
AND always from the designer grid has the possible values editable using a VS String Collection Editor.
Of Course the possible values is a [string()] array and can be changed also in runtime via the public property Values() of the object.
the 2 lines of JS related to the creation of the array and the bind to the TB
are automatically generated RIGHT @ rendertime.
The only stuff is to add the reference to the basics JSs (actb and common) only once per page, so if you are using a master add the refs to the 2 JSs only there, else in anypage that will use the actb.
if anyone is interested or esceially zic is ready for extending the article providing this server + designer version enchanced my mail is
uno.freeware@gmail.com
again, my work was zero intrusive, it's less' than 80 lines of good server code.no other change introducted.
If zic wwill not provide an extension, this is also meant as an official request for releasing the control on an article of mine.
FINALLY AND AGAIN, MAY ANY GOD BLESS ACTB from ZIC, i have found this one of the most helpful thing on the CP
I am trying to use this script and i have put some print lines in the script to see where it stops. Here is the section of the code
actb_curr = obj;
alert("actb_curr" + actb_curr);
addEvent(actb_curr,"focus",actb_setup);
alert("setup event called");
It prints the first alert like this (actb_curr[object]). But it doesn't print the 2nd alert. Also, i don't see any thing in my page when i start to type in in the text box. Please help.
Here is the code section from my html/jsp file.
ca = new Array('apple','pear','mango','pineapple',
'orange','banana','durian', 'jackfruit','etc');
I've tried actb.js, it worked well. But, where 'tat_tr' is declared and arrowkey moveup and movedown do not work properly. Could you please help and explain more in detail about this? Thanks,
Hi
Can someone help me to implement this in a right to left language?
I tried to replace "left" with "right" but it does not work.
For example there is no offsetRight in javascript.
There are two things that I did not manage with:
1. Put the table in the relevant possition.
2. Align the text in the table to the right.
Hi, I'm using this script and found it very simple to implement. Very nice work!
However I'm using an array of over 1000 elements, and it just doesn't works. As the array will be made from a mySQL table, which will grow and grow, I'd like to know what causes this stop; and, if someone knows, how to get rid of it.
You might have had an issue with some illegal characters. \ , . ' need to be stripped from the data. What seemed to me as a limitation to the number of records actually came down to the unacceptable characters.
For example I had a company called "John's Food Market" which causes issues.
Hope this helps.
Well I find the script very useful but I have a problem. I use several divs, and the list appears behind the other Divs, so I cannot see what it appears on the menu. Is there a way to set the list in top front. With css you can do it with z-index, but how schould I do that with the script?
thank you for your help