Anyone have any ideas on how to set the width for the dropdown to be fixed to my selection box? Also, I'd like to add a border to the dropdown list box, rather than color it. I'm relatively new to JavaScript and while I can do this on a normal div, I'm not there yet if I need to do it via script.
After
function actb_generate(){
if (document.getElementById('tat_table')){ actb_display = false;document.body.removeChild(document.getElementById('tat_table')); }
if (actb_kwcount == 0){
actb_display = false;
return;
}
a = document.createElement('table');
a.cellSpacing='1px';
you can add what you need - example - a.style.width='150px';
Dear Chun,
I can use your actb in html. But I cannot use it in ASP.Net 2.0.
The browser complains "object is needed".How can I use your function in
ASP.Net 2.0. Thanks.
I have to agree with r3kb. The function works very well and the download is nicely self-contained but the code is very difficult to read. May I suggest the following:
- more documentation in the code, the purpose of each function at the
very least,
- friendly variable names,
- use of line spacing where appropriate to help with ease of reading and
- be kind to your fellow developers by avoiding inlines like this:
"if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);"
Thanks for publishing your code!
- Alwyn
P/S: You might want to put your details in the Javascript files so we can give you proper credit.
I like the control quite a bit, but I find that the code it's based on is difficult to read. I would hope that a choice would be made to change to code that self-documents more. Over time, I've learned that commenting every line of code is more distracting than helpful. Code that self-documents uses variable and method names that describe what each is used for. IMNSHO, comments are best used to describe intent, nuances, and challenges. Single letter variables are okay for counters in loops, but it's easier to see what the counter is used for if it's descriptive...
Thanks for the tool and the article. I find it useful already, but I can see that in order to incorporate it into what I'm doing, I'll need to make some changes to it.
Hi ,
Here the requirement is when i type a letter "A" then it will retrive a set of values from database.Then i should use this auto complete instead getting all the values in an array and showing .Could please reply at earliest.
In php, I did it like following, and it's working perfect (although I have a problem with positioning in my thickbox...):
1) retrieve all values from the database and put them in a string (indeed, not a php-array!)
<br />
$rs=mysql_query("select name from table");<br />
$aantal=mysql_num_rows($rs);<br />
$i=1;<br />
while(list($name)=mysql_fetch_row($rs))<br />
{ if($i<$aantal) $array_names.="'$name',";<br />
//if it's the last item from the series, don't put a comma after the value<br />else $array_names.="'$name'";<br />
$i++;<br />
}<br />
2. Put the following at the place where you want to show the values (the php-string will just be echoed in the javascript):
<br />
<script><br />
var customarray = new Array(<<??php echo $array_names; ??>>;<br />
var obj = actb(document.getElementById('names'), customarray);<br />
</script><br />
And you're done!
I suppose that the approach will be similar in other languages like ASP.
Good luck!
P.S. It seems that this site is blocking the php-tags , so for that reason you have to change the line with 'var customarray' etc. in step 2...
I got one question, is this tested on newer browser such as Google Chrome or Safari or it's just IE and Firefox?
I tried it on Chrome and it doesn't work. Am I doing something wrong or it's not supported?
Hi,
I use actb for populating names and the names coming is a dynamic list prepared by ajax.
Once the names are populated the actb works fine but as soon as the dynamic list is changed the mouse events stops working..
Please help.....
Comments
1. Pg up / pg down support, I get and error using pg down
2. A shortcut to show the list without needing a match would be perfect, allowing it to function almost like a dropdown with autocomplete
This is absolutely flawlessly incredibly great. I wish I could use the up and down arrows to start showing pre-registered options before typing anything, but it's already great as it is. Thanks!