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 "an apple"..so when ever i type "app" in the textbox and then press enter ..it takes the word "an apple" from the autosugessted list .
example 2..if i type "king"..and then press enter it automatically takes "kingbird"..
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
I downloaded your Auto-complete code sample from "http://www.codeproject.com/script/Articles/ArticleVersion.aspx?aid=8020&av=41368" to implement an on-line translator. I would like to know how to implement auto-complete control with external js file?
Within function actb_checkkey(), the switch() statement checks for the Up, Down, Enter and Tab keys. If you add one more case statement, you can allow the user to hide/cancel the displaying list:
If this is added before the final default:, no other code is needed, and you can start typing your text in the autocomplete form, hit ESC, and the suggestion box disappears.
One suggested given for this code is to create a new instance of actb(). If you want to modify the array after it has been saved, be sure to capture the returned object:
var customarray_description = new Array();
var obj_description_school = new actb(document.getElementById('school'), customarray_description);
var customarray_code = new Array();
var obj_code_school = new actb(document.getElementById('school'), customarray_code);
obj_description_school.actb_keywords = a_different_customarray_description;
...
Changing the color hides the dropdown highlighting, but what I am seeking is something different.
If my list was populated with "Item1", "Item2", "Item3", and I type in "Item" then press [Enter], the script Automatically auto-completes the text in the textbox to become "Item1", as "Item1" gets highlighted BY Default (AS it is the first entry in the list).
I would like to perform a search for "Item". So I would like to type in "Item" then [Enter], without automatically selecting the first highlighted item in the list, in this case "Item1" gets selected and the action is performed.
Pretty much, how can I Modify the script SUCH that NO items are selected by default. I think this would solve my issue.
OK so i've been working on this code solid for 24 hours now and could really do with some help, I'm sure it's nothing much, but I don't have much experience with javascript.
<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%
dim objRs
dim arrPDFs
dim javascriptArrayValues
Function GetPDFsArray()
Set connString = Server.CreateObject("ADODB.Connection")
set objRS = Server.CreateObject("ADODB.Recordset")
connString.ConnectionString ="dsn=floor;uid=floor;pwd=floor;"
connString.Open
mySQL = "SELECT * FROM Companies"set objRs = connString.Execute(mySQL)
If NOT objRs.EOF OR NOT objRs.BOF Then
GetPDFsArray = objRs.GetRows()
Else
GetPDFsArray = ""
End If
End Function
'Get array
arrPDFs = GetPDFsArray
If isArray(arrPDFs) Then
for i=0 to uBound(arrPDFs,2)
javascriptArrayValues=javascriptArrayValues & """" & arrPDFs(0,i) & """" & ","
next 'i
javascriptArrayValues=Left(javascriptArrayValues,Len(javascriptArrayValues)-1)
Else
javascriptArrayValues = "Error: No results for array"
End If
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<input type="text" name="pdfDesc" id="pdfDesc" autocomplete="off" />
<script>
customarray = new Array(<%=javascriptArrayValues%>);
actb(document.getElementById("pdfDesc"),customarray);
</script>
</head>
<body>
</body></html>
As I said the page loads, but the autocomplete does nothing.
Thanks in advance to anyboby that takes the time to read this.