|
Hi Dmitry Khudorozhkov,
Thanks for a great control. I have one query. I'm using server url to fetch the list to show in dropdown list. The list of items keeps adding dynamically in the database. For suppose I typed "A" and items matching "A" are displayed... in the same moment, some more items matching "A" are added to the database. But when I type "A" again, only previously listed items are shown, the newly added items are not fetched. I think javascript is caching the items. I tried to set "actb_fullRefresh"=true, but no change. Please let me know how to solve this, it will be very helpful to me...Thanks in advance.
Priyatam K
|
|
|
|
|
Got the solution myself. Added a random number to end of server url as query string. Now it fetches the refreshed data also...
Thanks
Priyatam K
|
|
|
|
|
Hi Dmitry,
Great work. Thank you for fixing the select using mouse.
I would like to share with you a change I made to enable the control to list all suggestions on arrow down using Ajax.
The following code change worked for me (although I have not tested it under all possible circumstances, so I apologize if i appear to dabble in things i don't understand ).
The change I made is within Your function "done: function(ot, t)" in autosuggest.js
//Original code (line 1137):
if(!this.actb_curr.value.length)
{
for(i = 0; i < al; i++)
{
this.actb_keywords[i] = this.actb_keywords_init[i];
this.actb_values[i] = this.actb_values_init[i];
this.actb_bool[i] = true;
}
}
if(!this.actb_curr.value.length)
{
for(i = 0; < al; i++)
{
if(this.actb_firstText) this.actb_keywords[i] = this.actb_keywords_init[i];
this.actb_values[i] = this.actb_values_init[i];
this.actb_bool[i] = true;
}
}
modified on Saturday, February 23, 2008 10:27 PM
|
|
|
|
|
Hi,
first of all thanx to your work for this great component.
But i have a problem on IE 6 and 7: dont get javascript errors but suggest box (from ajax request, querying a aspx page that returns <listdata> xml) dont appear at all.
Is there any workaround or particular setup to fix this behaviour?
Thanx in advance for your attention.
|
|
|
|
|
Hi,
ShArDiCk wrote: But i have a problem on IE 6 and 7: dont get javascript errors but suggest box (from ajax request, querying a aspx page that returns xml) dont appear at all.
Very strange. Can you check, if your browser gets the response from the server? (just find the line:
xmlDocument = http.responseXML;
and put an alert:
alert(http.responseText);
after it. I think the problem is due to your security restrictions (either browser's, or firewall's).
Hope it helps,
- Dmitry.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
|
hi,
i really like the script.
would it be possible to get results from MS access db? i use classic asp.
im a newbiew in this, so any help would be great.
if this is not possible, is it possible when searching from xml, to search <description>, <details> so that users when wrote cola, can get result in the testfield?
Example my XML:
<description>Cocacola light</description>
<details>CocaCola, light, cola, blah blah....</details>
<description>Cocacola</description>
<details>CocaCola, perfect drink, blah blah....</details>
Hope u know what i mean
thanks
modified on Sunday, February 17, 2008 3:40 AM
|
|
|
|
|
Great job on the script for the autosuggestcontrol, I can get it to work on my project, but some other events stopped working when I added the functions to my existing textboxes.
I had a watermarktext indicating what to write in the textbox which showed or dissapeared depending on there was a text or not in the textbox, I use the events onfocus and onblur to do this.
After connecting the autosuggest script to the textboxes it is not working. It's probably because these events are beeing used in the autosuggest script as well, but I am not very good at javascript and can't seem to find out where in the autosuggest.js script to put my own script so I can get the original function to work with the autosuggest.
Any ideas?
Thanks!
/e
|
|
|
|
|
Found it!!
Put the code I used on onfocus in actb_setup, and the code for onblur in actb_clear. It works fine for my purpose.
/e
|
|
|
|
|
The following HTML and XML pages make use of an external XML file instead of a static Javascript array, as illustrated in Dmitry's code. The code has been tested and works with IE7 and FF2.
-- autosuggest-external_data_island.htm
<html>
<head>
<script type="text/javascript" src="autosuggest.js">
</script>
<title></title>
</head>
<body>
<form>
<input type='text' style='font-family:verdana;width:300px;font-size:12px' id='tb' value='' />
<script type="text/javascript">
//XML file loading routine - load the external xml data island into an array, so we can use it to populate the customarray
//populate all of the words into this array
var customarray = new Array();
// code for IE
if (window.ActiveXObject)
{
//alert ('IE')
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.load("items.xml");
}
// code for Mozilla, etc.
else if (document.implementation && document.implementation.createDocument)
{
//alert ('FF')
var xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.async = false;
xmlDoc.load("items.xml");
}
// code for other browsers
else
{
alert('Your browser cannot handle this script');
}
var words = xmlDoc.getElementsByTagName('WORD');
//loop through all "WORD" tags
//alert (words.length);
for (i=0; i < words.length; i++)
{
//add them to the array
customarray[i] = words[i].firstChild.nodeValue;
//alert (customarray[i]);
}
//create the auto-completion text box object
new actb('tb', customarray);
</script>
</form>
</body>
</html>
-- items.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GLOSSARY>
<ITEM>
<WORD>abracadabra</WORD>
</ITEM>
<ITEM>
<WORD>apple</WORD>
</ITEM>
<ITEM>
<WORD>alligator</WORD>
</ITEM>
<ITEM>
<WORD>banana</WORD>
</ITEM>
<ITEM>
<WORD>elephant</WORD>
</ITEM>
<ITEM>
<WORD>pear</WORD>
</ITEM>
<ITEM>
<WORD>kingbird</WORD>
</ITEM>
<ITEM>
<WORD>kingbolt</WORD>
</ITEM>
<ITEM>
<WORD>kingcraft</WORD>
</ITEM>
<ITEM>
<WORD>kingcup</WORD>
</ITEM>
<ITEM>
<WORD>kingdom</WORD>
</ITEM>
<ITEM>
<WORD>kingfisher</WORD>
</ITEM>
<ITEM>
<WORD>kingpin</WORD>
</ITEM>
</GLOSSARY>
|
|
|
|
|
Would it be possible, to have something similar to get results from MS access db in asp??
|
|
|
|
|
Yes, and it's not too difficult to implement. Essentially, you want to create a data connection, open the connection, loop through and add each record to a new array, and then use this array to populate the control.
You should be able to find some easy demos for data connections and arrays in asp.
Codeproject.com has a good introduction to database connections.[^]
This article[^] demonstrates both connecting to and looping through the database. This should help you.
modified on Saturday, March 15, 2008 8:08 PM
|
|
|
|
|
I have installed the script with a static client-side array. This works without any problem.
Now I have tried to implement AJAX using php. Without any success.
I used the following code:
<?php
$host = "localhost";
$database = "mydatabase";
$user = "myuser";
$password = "mypassword";
mysql_connect($host,$user,$password);
mysql_select_db($database);
$sql = "SELECT email FROM address WHERE email LIKE '%" . $_POST['search'] . "%'";
$rs = mysql_query($sql);
?>
<listdata><? while($data = mysql_fetch_assoc($rs)) { ?><? echo stripslashes($data['email']);?>|<? } ?></listdata>
Firefox shows the following syntax error:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">-------------------------------------------------^
What have I done wrong?
Edi
modified on Friday, January 18, 2008 11:27:31 AM
|
|
|
|
|
edi_g wrote: What have I done wrong?
Try to add the following at the start of the PHP script:
header('Content-Type: text/xml');
You don't explicitly specify the content-type, so Firefox assumes it is HTML = you get an error.
P.S. By the way - don't forget to prepend your XML data with:
<?xml version=\"1.0\"?>
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
modified on Friday, January 18, 2008 11:21:52 AM
|
|
|
|
|
Thank you for the fast reply! I will try this on Monday...
Edi
|
|
|
|
|
It seems, that not the PHP script is the problem, but the code in the HTML page.
As you suggested I use the follwing:
<input type="text" name="name" id="tb" value=""><br />
<script><br />
var obj = new actb('tb', '', 'http://www.myserver.com/listdata.php');<br />
</script></input>
Edi
P.S. I mail you a link where you can have a look in the application.
|
|
|
|
|
Thank you for the support!
I post here the solution, if others have the same problem:
Use
http://www.myserver.com/listdata.php?str=
instead of
http://www.myserver.com/listdata.php
Edi
|
|
|
|
|
Nice, but i m not able to work on ajax feature as in asp.net as you tell in artical can u provide some example??
It will be very help full to me
|
|
|
|
|
This code is not (yet) ready to work easily with ASP.NET - if you can't make it work, you should probably try MicroSoft's AJAX library instead.
ASP.NET control based on this code is in the works.
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
hey it work now i just make some changes in your javascript to make it work,
i got problem in
xmlDocument = http.responseXML
which give me error in my code.
Insted of this i use
xmlDocument = http.responseText
and it's work fine. (may it help your asp.net development..
i like your code.
Ya its always be a option to use microsoft ajax lib but personally i avoid to use (specially in autosuggest feature it.
Viral
YahooID : just_viral
|
|
|
|
|
I had to add:
Response.AddHeader("Content-Type", "text/xml")
to get the script to work as is.
|
|
|
|
|
great idea thanks
Viral
YahooID : just_viral
|
|
|
|
|
thanks a lot! I really love your control.
But I only wonder one thing, the 10th january update, is it only the beta version that is updated?
When I now download the "stable" version, all the files has 2007-09-20 as date modified
|
|
|
|
|
Hi,
the latest code update is quite mature - so you can safely download it. I will remove the 2nd link on the next update.
- Dmitry.
-------------------------
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Hi Dmitry,
This is Sandip from India. Thanks for the wonderful post in code-project about implementing auto-suggest capability. I have a scenario in which I have implemented the same, but facing one problem. I have an asp dropdownlist, and depending on the value in the drop-down list, I want my suggestions to come. For example, when I select "Well Name" in the dropdown list I want only the well names to be suggested in the corresponding input-box. The suggestions are coming fine. When I click on any suggested option (suppose "A Rust 1"), the same is getting displayed in the input-box. So this is fine, but happens for the first time.
N ow if I change the value in the drop-down to suppose "Facility Name", the suggestions are coming fine, but when I click on any suggested value ( suppose "Shelton 2"), the same is NOT getting displayed in the input-box.
I guess there is some issue with the click event of the suggested options. I have sent you a mail with detailed screenshot.
Can you please suggest why this error is coming? It will be really great, if you can give any solution to this.
|
|
|
|