|
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.
|
|
|
|
|
Is there a script based solution to disable the browser autocomplete (because the menu with suggestions opens behind the browser autocomplete)?
Edi
|
|
|
|
|
Sorry for the dumb question... I found the solution by myself and added autocomplete="off" to the form-tag.
Edi
|
|
|
|
|
HI
I am using your code for autosuggest functionality, and its been fantastic. Though there is small request, I have to add a down key functionallity so that even when the textbox is empty the user can see the entire list with a downKey press. Could you provide a patch or suggest the modifications needed for the successful implementation of the above mentioned feature.
Regards
Ayush
|
|
|
|
|
Hi!
To show the whole list using a special sign (e.g. "?") you only have to add one line and to change an other line in autosuggest.js.
Within "function actb(id, ca, url)"
define the new public variable
this.actb_show_all = '?'; // show widget with the whole list when '?' is typed in.
Look for the line "done: function(ot, t)"
(this should be line 1104 or nearby)
and some lines later (line 1118) change the statement
if(re.test(this.actb_keywords[i]))
to
if((re.test(this.actb_keywords[i])) || ot == this.actb_show_all)
If you enter the sign you defined in the variable this.actb_show_all
(here '?') in your input field the whole list will be shown.
You may choose any suitable sign not used within the list itself (e.g. '*' instead of '?') for the variable this.actb_show_all to indicate, that the whole list should be displayed.
Good luck!
|
|
|
|
|
Thank you for this component.
Please include version/date in your source files. You are mentioning new versions as of october 30th, but it's unclear whether you actually posted this new version.
Bugs I've found:
When actb_firstText=false, and you type 'au', audi is being shown, when appending the 'd', the suggestion box highlights 'audi'. So if you actually want to search for the term "aud" and you type it slowly and press enter, you will be searching for "audi".
Regards
|
|
|
|
|
I think the date in the top right corner will change when this page is updated. Doesn't necessarily mean a version change, but it will give you some idea. A version number in the file is still a good idea.
Posted: 24 Aug 2007
Updated: 11 Oct 2007 <--- This
Views: 22,538
|
|
|
|