Last Chance! Up to 65% OFF DMXzone with DMXBF26 & 30% OFF Wappler yearly plans with WAPPLERBF26. Less than 24 hours left!

Ajax AutoComplete Support Product Page

This topic was archived

Autocomplete with error on table ?!

Reported 23 Apr 2009 21:11:25
1
has this problem
23 Apr 2009 21:11:25 Andreas Knapp posted:
Hello,

also i have DW CS4 with SQL Server 2005 on a Windows Server 2008.
Here is a table called "T_PLZ05idnr02" there is some rows looks like this:

In english:
IDNR Postalcode Townname Bordername
In german at my sql2005 database table
IDNR PLZ Gemeindename Kreisname
some rows:
1 15236 Frankfurt Frankfurt (Oder)
2 65936 Frankfurt Frankfurt am Main

my autocomplete.asp looks like this:

Dim sTable
sTable = "dbo.T_PLZ05idnr02"
Dim sPrimary
sPrimary = "Gemeindename"
Dim sOptional
sOptional = "PLZ"

if i make this i will get TWO rows on the input textfield for my website. this is "Frankfurt" with 15236 PLZ and also "Frankfurt" with 65936 PLZ.

IF
i make this in the autocomplete:

Dim sTable
sTable = "dbo.T_PLZ05idnr02"
Dim sPrimary
sPrimary = "Gemeindename"
Dim sOptional
sOptional = "Kreisname"

i will get O N L Y the "Frankfurt" with 65936 PLZ in the drop-down-menue from autocomplete....WHY

I dont understand...i tried something in the autocomplete-Site010-asp-1.asp but nothing will help !!!!???

- Should i sent the orginal files via eMail?
- But i have nothing special done. only changes the database-fields from PLZ to Kreisname.


here is the rest of the information for this:
<

%'--jszone (DO NOT REMOVE THIS)

Dim sTable
sTable = "dbo.T_PLZ05idnr02"
Dim sPrimary
sPrimary = "Gemeindename"
Dim sOptional
sOptional = "Kreisname"

'--jszone (DO NOT REMOVE THIS)

Dim Sql
Dim rsXml
Dim rsXml_cmd
Dim sString, nLimit, sContains, sLike, aOptionals

Dim arrOptinal

sString = ""
If (Request.QueryString("q") <> "") Then 
  sString = Request.QueryString("q")
End If

nLimit = 5
If (Request.QueryString("limit") <> "") Then 
  nLimit = CLng(Request.QueryString("limit"))
End If

if sOptional <> "" then
	sOptional = "," & sOptional
end if

sContains = ""
If (Request.QueryString("mc") <> "") Then 
  sContains = "%"
End If

sLike = ""
sLike = sPrimary & " LIKE '" & sContains & Replace(sString,"'","''") & "%'"
If (Request.QueryString("sa") <> "") and sOptional <> "" Then 
  aOptionals = Split(sOptional,",")
  for ai = 1 to UBOUND(aOptionals)
    sLike = sLike & " OR " & aOptionals(ai) & " LIKE '" & sContains & Replace(sString,"'","''") & "%'"
  next
End If

Sql = "SELECT "
if nLimit > 0 then
	Sql = Sql & " TOP " & nLimit & " "
End if
Sql = Sql & sPrimary & sOptional &  " FROM " & sTable & "  WHERE " & sLike

Set rsXml_cmd = Server.CreateObject ("ADODB.Command")
rsXml_cmd.ActiveConnection = MM_conDBAKi201_STRING
rsXml_cmd.CommandText = Sql
rsXml_cmd.Prepared = true

Set rsXml = rsXml_cmd.Execute

Response.ContentType = "text/plain"

if not rsXml.EOF then
	Response.Write rsXml.GetString(,,"|",vbCRLF,"")
end if

rsXml.Close()
Set rsXml = Nothing
%>


and in the Site010.asp:
       <input name="Ort" id="Ort" type="text" class="InputOrtAC" tabindex="2"  onFocus="MM_changeProp('Ort','','backgroundColor','#C7DFFF','Ort')" onFocusout="MM_changeProp('Ort','','backgroundColor','#FFFFFF','Ort')"/>
        <script type='text/javascript'>
$(document).ready(
function() {
jQuery('#Ort').autocomplete('autocomplete-Site010-asp-1.asp',
{
	opacity : .7,
	delay : 100,
	autoFill : true,
	multiple : false,
	minChars : 3,
	max : 10,
	searchAll : true,
	matchContains : true,
	highlightClass : 'ac_highlight',
	inputClass : 'ac_input',
	loadingClass : 'ac_loading',
	resultsClass : 'ac_results',
	fxShow : { type:'slide' },
	fxHide : { type:'slide' }

})});
        </script>

Reply to this topic