|
Hi!
First i wanna thank you for your great work with this auto-suggest
I was wondering if there can be a way to add an multidimensional array o make something like this:
I have a query:
select name1, name2 from table
while(mysql_fetch_array){ ..... }
And i want to display both results (name1,name2) in the same textfield without concatenate:
new autosuggest("part", customarray[name1][name2]);
E.G
table contains:
columns: name1 name2
values:
name1 : anim,asdf
name2 : beast,bee
input with auto-suggest shows all values with letter a:
anim
asdf
Thanks for your time and your awesome code 
modified 5-Oct-13 15:17pm.
|
|
|
|
|
|
Hi i am using this autosuggested textbox .
Auto-suggest Control[^]
Problem Description:
1) i am selecting one item from this auto suggest and store this in local storage .
it is fine .Example store name " naveen"
2)Problem is that when user select another name from list and change it mind after writing some text in field say "hn".click somewhere else auto suggest is close. but i need to display that time in text field last storage example ="naveen"
|
|
|
|
|
Thanks for this wonderful script. This is one of the best script for autocomplete textbox.
While trying to implement AJAX solution having an issue with filtration based on dropdown. Basically based on dropdown value selected I want to populate auto suggestion in the textbox.
Please do let me know whats wrong with my code...Any help appreciated and thanks in advance!!
Issue:
1. Based on dropdown list selection, I want to populate corresponding autosuggest list.
2. Dropdown default selected to 'FullName'/ 'Name'. When I change dropdown to Employee ID. It performs search on 'FullName'
3. I'm calling CreateInstance function from dropdown list and in form tag
Code snippet:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestPage.aspx.vb" Inherits="Test.TestPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" language="javascript" src="autosuggest.js"></script>
<script language="javascript" type="text/javascript">
function CreateInstance(id, searchfield)
{
new autosuggest(id,'','AutoComplete.aspx?SearchField='+searchfield+'&SearchTerm=');
}
</script>
<table cellSpacing="1" cellPadding="1" width="100%" border="0" ID="Table1">
<tr bgColor="#ffffff" valign="middle">
<td align="center" height="21" class="headtext">Search Criteria:
<asp:dropdownlist onchange="javascript:CreateInstance(document.getElementById('txtFieldValue').name, this.value);"
id="ddlFieldName" runat="server" Width="150px">
<asp:ListItem Value="SELECT">Select Criteria</asp:ListItem>
<asp:ListItem Value="ALL">All Users</asp:ListItem>
<asp:ListItem Value="EmployeeID">Employee ID</asp:ListItem>
<asp:ListItem Value="FullName" Selected="True">Name</asp:ListItem>
<asp:ListItem Value="WorkPhone">Work Phone Number</asp:ListItem>
</asp:dropdownlist> <asp:textbox id="txtFieldValue" runat="server" Columns="30"></asp:textbox>
<asp:button id="btnSearch" runat="server" Text="Search"></asp:button></td>
</tr>
</table>
<script language="javascript" type="text/javascript">
CreateInstance(document.getElementById('txtFieldValue').name, document.getElementById('ddlFieldName').value);
</script>
</form>
</body>
</html>
|
|
|
|
|
Bascially I want to release old/ previous object of autosuggest and create new instance every call...
new autosuggest(id,'','AutoComplete.aspx?SearchField='+searchfield+'&SearchTerm=');
|
|
|
|
|
finally got it!!!
Solution:
Used code-behind
Page.RegisterStartupScript("AutoSuggest", "<script type='text/javascript'>new autosuggest('" & SearchForValue & "','','AutoComplete.aspx?SearchField=" & SearchConditionValue & "&SearchTerm=');</script>")
|
|
|
|
|
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 "audi"..so when ever i type "au" in the textbox and then press enter ..it takes the word "audi" from the autosugessted list .
example 2..if i type "maz"..and then press enter it automatically takes "mazda"..
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
thanks in advance
|
|
|
|
|
there is a problem when using this control for opening ajax request which having arabic querystring.
i modify autosuggest.js line 1227 by this :
http.open("GET", this.suggest_url + encodeURIComponent( ot_), true);
Fawzia Mohammed
Senior Web Developer
|
|
|
|
|
Hey i have a problem with IE 6, take a look at the screenshot:
LINK
|
|
|
|
|
This is what im looking for...but im a new in asp, and im doing my webpage in asp...i need to know how conect the suggets to a access db to get the options....tks so much for your help
|
|
|
|
|
My 5 for a great Article.
|
|
|
|
|
Great piece of software, thanks
|
|
|
|
|
Can someone please look at this and tell ,me why the AutoSuggest asp-vb code does not work!
Well, I figured it out, it was an ID Ten T (or Id10t) problem. Note the "kingcup' double and single quote mix!!!
Change to double code and problem is fixed.
By the way either 'kingcup' or "kingcup" will work
NOTE: In the original code that can be copied it has "kingcup' in it !!
Dmitri : If you have a chance, please correct the entry
<HTML><HEAD>
<link rel="stylesheet" type="text/css" href="autosuggest.css"></link>
<script type="text/javascript" src="autosuggest.js"></script>
<script>
var customarray = ["apple", "alligator", "banana", "elephant",
"pear", "kingbird", "kingbolt", "kingcraft",
"kingcup", "kingdom", "kingfisher"];
</script>
</HEAD>
<!-- Instruction : http:
<body>
<table border="4" width="100%" align = "center" bgcolor="#c0c0c0" id="table1" cellpadding = 1 cellspacing = 1 >
<tr><td colspan="1" ><p align="center">Test Auto AutoSuggest (apple, Kingbird, etc)</p></td> </tr>
<tr><td colspan="1" width="50%" >Current test list : ??<%=customarray%>??</td></tr>
<tr><td colspan="1" width="50%" >
<input type="text" id="tb" value="" style="font-family:verdana;width:300px;font-size:12px" />
<script > var obj = new autosuggest("tb",customarray ); </script>
</table>
</body>
</html>
Thanks, Henry
Detroit, USA
|
|
|
|
|
Can someone help me with my problem?
I want to be able to pick string value from textbox and return id value that will be send with form.
for example:
I have
<input type="text" id="id_" value="" />
<script type="text/javascript">
var arr = new Array();
arr.push(new Array("xx", 1);
arr.push(new Array("yy", 2);
arr.push(new Array("zz", 3);
var obj = new autosuggest("id_", arr);
</script>
and I want to see the "xx", "yy", "zz" when I use autosuggest textbox and after I pick for example "xx" I want the id_ from field to have 1 value that can be send with
|
|
|
|
|
Hi Dmitry..
i'm just a newbie in the jsp..
can you explain, how to send .xml data into the autosuggest in jsp..
Thanx in advance. 
|
|
|
|
|
I've got auto-suggest working perfectly. It's great. I can use multiple text fields without any problems, except when I put the field within a form.
This is test code that works for the built-in array and for server side auto-suggest. Works perfectly in both cases.
When I had this working, I'd thought that I would have no problems getting this into real code.
<html>
<head>
<link rel="stylesheet" type="text/css" href="autosuggest.css"></link>
<script type='text/javascript' src='autosuggest.js'></script>
<script>
var customarray = ["apple", "alligator", "banana", "elephant",
"pear", "kingbird", "kingbolt", "kingcraft",
"kingcup", "kingdom", "kingfisher" ];
</script>
</head>
<body>
<input type="text"
id="tb" value=""
style="font-family:verdana;width:300px;font-size:12px" />
<script>
var obj = new autosuggest("tb", customarray);
</script>
<input type="text" id="tb2" value="" style="font-family:verdana;width:300px;font-size:16px" />
<script>
var obj = new autosuggest("tb2", "", "http://127.0.0.1/autosuggest.wsgi/?field=npi&s=");
</script>
</body>
</html>
For whatever reason, auto-suggest is not reading in the strings from the fields when it's in a form.
<form id="subForm" name="subForm" method="post" onSubmit="return verifyForm(this);" action="http://127.0.0.1/retrieve.wsgi">
<div class="box">
<h2>Store information</h2>
<p>
<label class="label">NPI#</label><input type="text" name="npi" id="npi" />
<script type="text/javascript">
var obj = new autosuggest("npi", "", "http://127.0.0.1/autosuggest.wsgi/?field=npi&s=");
</script>
</p>
I've tried changed the ids passed to autocomplete but that didn't work. I followed the code using Firebug and I can see that the code isn't failing but it's not finding the text from the field.
On about line 35, I can see that the correct field id is being assigned.
function autosuggest(id, array, url, onSelect)
{
var field = document.getElementById(id);
The form actually contains about 15 fields. Rather than having the users guess what might data might actually be present in the database for that field, I'd like to present the most likely data first.
I'd greatly appreciate any assistance or guidance you can provide.
Thank you.
modified on Saturday, December 4, 2010 1:42 PM
|
|
|
|
|
 Good morning Joanne,
I've just tested the script with the following page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Autosuggest control test page</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<!-- Page styles: -->
<style type="text/css">
input
{
font-size: 12px;
font-family: verdana;
}
table
{
width: 100%;
text-align: center;
}
td
{
vertical-align: top;
}
</style>
<!-- Autosuggest control's includes: -->
<link rel="stylesheet" type="text/css" href="styles/autosuggest.css"></link>
<script type="text/javascript" src="scripts/autosuggest.js"></script>
</head>
<body>
<form id="subForm" name="subForm" method="post" önSubmit="return verifyForm(this);" action="http://127.0.0.1/retrieve.wsgi">
<table>
<tr>
<td>
<!-- Installation with the webservice as a back-end: -->
<input type="text" id="target" size="40" value="" />
<script type="text/javascript"> new autosuggest("target", null, "http://localhost/Autosuggest/autosuggest.php?q="); </script>
</td>
</tr>
</table>
</form>
</body>
</html>
(I have Apache server on the "localhost")
- and everything worked great. Can you please check 2 things:
1. Does the page send the data? You can check if the request is made with TamperData extension for Firefox.
2. Please try to add the XHTML declaration. Not sure about this, though - for me everything worked without it.
If you wish - I can send you the whole testbed with PHP/MySQL code.
Even better - maybe any public page for me to test?
Best regards,
Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
How don't know how I stumbled upon this autocomplete="off" directive but I tried it and it worked! Now each field successfully works.
<form id="subForm" name="subForm" method="post" onSubmit="return verifyForm(this);" action="http://127.0.0.1/retrieve.wsgi" autocomplete="off">
Thank you.
|
|
|
|
|
Well, it seems that browser's history somehow interfered with the auto-completion.
I didn't notice it, because my privacy options are maxed out, so field history is not recorded.
Thank you for letting me know, anyway
- Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
First, very nice functionality!
It would be good to be able to give the id of the destination of selected value as an argument.
such that when you select a value, it is transferred to a "read-only" text-field, thus ensuring that the user doesn't write anything wrong.
|
|
|
|
|
Hi Pascal,
pascal_a wrote: It would be good to be able to give the id of the destination of selected value as an argument.
current code already has the callback function - it's very task is to allow you to do whatever you want to do. You can just get the field from inside the callback and assign it's value to the selected one, voila
Regards,
Dmitriy.
Listen up! "Teamwork" means staying out of my way! (Seifer, Final Fantasy 8).
|
|
|
|
|
Yes. You are right
Thanks for the quick answer.
|
|
|
|
|
I have a couple of questions regarding the ajax call
1, can the url have parameters? I would like to call a perl script and pass 2 parameters to it like year and model.
2, why do you need the question mark at the end of the url string?
here is what I would like to use
var line = 'FieldId';
var url = "vin.pl?Year="+year+"&Model="+model;
asbbox[line] = new autosuggest(line, '', url);
The file that is sent to the browser from the perlscript is <pre><listdata>6_abc123_1989_HONDA_CIVIC_JHMED3543KS803978|680__1989_HONDA_CIVIC_JHMED3643KS801632|1002__1989_HONDA_CIVIC_JHMED7362KS801537|1140__1989_HONDA_CIVIC_JHMED3641KS800205|1171__1989_HONDA_CIVIC_JHMED6303KS800659|1197__1989_HONDA_CIVIC_JHMED9361KS800116|1404__1989_HONDA_CIVIC_2HGED6306KH002649|2194__1989_HONDA_CIVIC_2HGED6304KH002830|2443__1989_HONDA_CIVIC_JHMED9360KS800785|2636__1989_HONDA_CIVIC_JHMEE2753KS800110|3193__1989_HONDA_CIVIC_JHMED8357KS800137|3299__1989_HONDA_CIVIC_1HGED3643KA800053|3750__1989_HONDA_CIVIC_JHMED835XKS800276|3808__1989_HONDA_CIVIC_JHMED3508KS801656|3884__1989_HONDA_CIVIC_JHMED8355KS800167|4195__1989_HONDA_CIVIC_JHMED936XKS800177|4255__1989_HONDA_CIVIC_1HGED3645KA802130|4644__1989_HONDA_CIVIC_JHMED9366KS801858|4811__1989_HONDA_CIVIC_JHMED9363KS801705|5065__1989_HONDA_CIVIC_1HGED3509KA804056|5480__1989_HONDA_CIVIC_JHMED936XKS801149|5705__1989_HONDA_CIVIC_JHMED6341KS801246|7834__1989_HONDA_CIVIC_2HGED6336KH003021|8664__1989_HONDA_CIVIC_1HGED3604KA802486|8728__1989_HONDA_CIVIC_JHMED3608KS800120|8746__1989_HONDA_CIVIC_2HGED630XKH002864|10732__1989_HONDA_CIVIC_JHMED3500KS801487|10736__1989_HONDA_CIVIC_2HGED7360KH012023|10738__1989_HONDA_CIVIC_1HGED3546KA801814|10739__1989_HONDA_CIVIC_1HGED3540KA803929|10741__1989_HONDA_CIVIC_JHMED6301KS802765|10946__1989_HONDA_CIVIC_JHMED3541KS803249|11046__1989_HONDA_CIVIC_JHMED630XKS803302|11189__1989_HONDA_CIVIC_1HGED3641KA804344|15763__1989_HONDA_CIVIC_JHMED9363KS800098</listdata></pre>
Thanks for your help with this. The autosuggest version I am using is 2.3.
|
|
|
|
|
I know this is an old post, but I got parameters to work correctly by putting a "&" the end of my ajax url (ie, after my last argument). The code appends an additional argument to the url. That is why you have to have the '?' at a minimum at the end.
|
|
|
|
|
Nice script. Unfortunately there is at least one limitation. The auto suggest fails if the leading character in one of the array items is an asterisk.
i.e This works:
var custom_array_2 = [['audi**,test', 1], ['bentley', 2]];
This does not:
var custom_array_3 = [['**audi,test', 1], ['bentley', 2]];
|
|
|
|
|