Hello to Bob Barrows,
I went and tried out your ListDemo asp. My proficiency
in asp/vbscript/xml is kind of meager. I got an error
message with your script. I type in server name, ID,
pwrd, and one or two letters to list on and error out. I
placed a bunch of msgbox statements to debug. I can get
between the "1st if" and "2nd If" in sub txtCrit_onkeyup
in your clientside script below. Error message says:
"errorCode = -1072896759
reason=Required white space was missing.
Line =2
linepos = 55
filepos = 56
srcText = <!DOCTYPE HTML PUBLIC "-//WC3//DTD HTML 3.2
Final//EN">"
Is this error in the DTD? Here is your script. It would
be real cool if I could get it to work on my system.
<%@ Language=VBScri pt %>
<%Response.Buff er=true%>
<HTML>
<HEAD>
<META name="VI60_Defa ultClientScript " Content="VBScri pt">
<META NAME="GENERATOR " Content="Micros oft Visual Studio
6.0">
<SCRIPT ID=clientEventH andlersVBS LANGUAGE=vbscri pt>
<!--
dim sCurCrit
dim xmldoc
Sub window_onload
dim f
sUser = txtUser
sPwd = txtPwd
sServer = txtServer
if screen.availWid th > 800 then
tblMain.style.f ontSize="10pt"
end if
lstTitles.style .visibility="vi sible"
set xmldoc = nothing
End Sub
Sub txtCrit_onkeyup
dim sOptions, sKey, sCrit, oOption, oNodes,xmlFilt,
oNode,iCritLeng th
msgbox "entering txtCrit" 'my first error trap
'I have this set to retrieve data when there's a single
character entered.
'With 6000 rows, you may want to increase this to two
characters
sCrit=txtCrit.v alue
ClearList
sKey = chr(window.even t.keyCode)
msgbox "1st if and len of sCrit is " & len(sCrit) & "
and sKey is " & sKey 'my second error trap
if len(sCrit) > 1 then 'change to 2 for 6000 rows
'check to see if someone hit 2 letters so close
together that the elseif code
'never had a chance to execute and create xmlDoc
msgbox "2nd if" 'third error trap
if not xmlDoc is nothing then
set xmlFilt = CreateObject("M icrosoft.XMLDOM ")
'The following can be replaced by an xslt
transformation if you are so inclined
set xmlFilt.documen telement = xmlFilt.createe lement
("rows")
iCritLength = len(sCrit)
for each oNode in xmldoc.document element.childno des
if left(oNode.geta ttribute
("customerid"), iCritLength) = ucase(sCrit) then
xmlFilt.documen telement.append child
oNode.Clonenode (false)
end if
next
msgbox "xmlFilt"
fillList xmlFilt
set xmlFilt = nothing
else
sCurCrit = sCrit
set xmldoc = CreateObject("M icrosoft.XMLDOM ")
if RetrieveData(sC urCrit,xmldoc) then
msgbox "xmldoc1"
fillList(xmldoc )
end if
end if
elseif len(sCrit) > 0 then 'change to 1 for 6000 rows
if sCrit <> sCurCrit then
sCurCrit = sCrit
if RetrieveData(sC urCrit,xmldoc) then
msgbox "xmldoc2"
fillList(xmldoc )
end if
else
msgbox "xmldoc3"
fillList xmldoc
end if
end if
End Sub
-->
</SCRIPT>
<SCRIPT LANGUAGE=vbscri pt>
<!--
Sub ClearList
lstTitles.inner HTML=""
End Sub
Sub fillList(pxmlDo c)
'you could have used a data island and bound the
listbox to it, but
'I chose to do it this way
dim oNode
for each oNode in pxmlDoc.documen telement.childn odes
set oOption = document.create Element("OPTION ")
oOption.value = oNode.GetAttrib ute("orderid")
oOption.text = oNode.GetAttrib ute("customerid ") & _
" - " & oNode.GetAttrib ute("orderid")
lstTitles.optio ns.add oOption
next
end sub
Function RetrieveData(ps Crit, pxmlDoc)
dim oHTTP,xPE,bStat us, sUrl
RetrieveData = true
set oHTTP = CreateObject("M icrosoft.XMLHTT P")
set pxmlDoc = CreateObject("M icrosoft.XMLDOM ")
sUrl = "ListDemo_serve r.asp?P1=" & pscrit & "&User=" &
txtUser.value & _
"&Server=" & txtServer.value & "&PWD=" & txtPwd.value
oHTTP.open "GET",sUrl, false
oHTTP.send
bStatus= pxmlDoc.loadXML (oHTTP.response text )
if bStatus = false then
Set xPE = pxmlDoc.parseEr ror
strMessage = "errorCode = " & xPE.errorCode & vbCrLf
strMessage = strMessage & "reason = " & xPE.reason &
vbCrLf
strMessage = strMessage & "Line = " & xPE.Line &
vbCrLf
strMessage = strMessage & "linepos = " & xPE.linepos &
vbCrLf
strMessage = strMessage & "filepos = " & xPE.filepos &
vbCrLf
strMessage = strMessage & "srcText = " & xPE.srcText &
vbCrLf
set xPE = nothing
MsgBox strMessage,,"Re trieving Data"
RetrieveData=fa lse
end if
set oHTTP = nothing
end function
-->
</SCRIPT>
</HEAD>
<BODY bgColor=lightgr ey topMargin=2 leftMargin=2>
<DIV id=elHeading><S TRONG><FONT color=blue face=Verdana
size=3
style="BORDER-TOP-WIDTH: thin">
Orders Maintenance </FONT></STRONG></DIV>
<P>
<TABLE id=tblMain cellSpacing=1 cellPadding=1 width="75%"
border=1>
<CAPTION>This demo uses the Orders table in the Northwind
database</CAPTION>
<TR>
<TD>SQL Server Name: <INPUT id=txtServer></TD>
<TD> User Name <INPUT id=txtUser></TD>
<TD> Password <INPUT id=txtPwd></TD>
<TR>
<TD>Enter the first few letters of the last name of
the customer id whose data
you wish to view or edit:<BR><INPUT id=txtCrit
name=text1></TD>
<TD colspan=2><SELE CT id=lstTitles style="VISIBILI TY:
hidden; WIDTH: 252px"
size=8></SELECT>
</TD>
</TR>
</TABLE></P>
</BODY>
</HTML>
Thanks for sharing your script.
Rich
-----Original Message-----
J P Singh wrote: Hi There
We have dropdown on ASP page. The problem is we have
about 900 items in the dropdown. Users scrolling through the list have
become very frustrated in the past.
Can someone suggest if there is another way of
implement a dropdown where the datalist is as big as ours.
I am looking for something like a listbox in VB where
you can start typing the characters and the databelow moves
accordingly until you have found what you want.
Is there anything in ASP/HTML to achieve a similar
functionalityYou can do this in client-side code. Go to
http://www.thrasherwebdesign.com/index.asp?
pi=links&hp=lin ks.asp anddownload my dynamic listbox demo to see one way of doing
it. A Google searchshould find you other examples.
http://www.learnasp.com/learn/listdynamicmore.asp
Bob Barrows
.