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=VBScript %>
<%Response.Buffer=true%>
<HTML>
<HEAD>
<META name="VI60_DefaultClientScript" Content="VBScript">
<META NAME="GENERATOR" Content="Microsoft Visual Studio
6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
dim sCurCrit
dim xmldoc
Sub window_onload
dim f
sUser = txtUser
sPwd = txtPwd
sServer = txtServer
if screen.availWidth > 800 then
tblMain.style.fontSize="10pt"
end if
lstTitles.style.visibility="visible"
set xmldoc = nothing
End Sub
Sub txtCrit_onkeyup
dim sOptions, sKey, sCrit, oOption, oNodes,xmlFilt,
oNode,iCritLength
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.value
ClearList
sKey = chr(window.event.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("Microsoft.XMLDOM")
'The following can be replaced by an xslt
transformation if you are so inclined
set xmlFilt.documentelement = xmlFilt.createelement
("rows")
iCritLength = len(sCrit)
for each oNode in xmldoc.documentelement.childnodes
if left(oNode.getattribute
("customerid"),iCritLength) = ucase(sCrit) then
xmlFilt.documentelement.appendchild
oNode.Clonenode(false)
end if
next
msgbox "xmlFilt"
fillList xmlFilt
set xmlFilt = nothing
else
sCurCrit = sCrit
set xmldoc = CreateObject("Microsoft.XMLDOM")
if RetrieveData(sCurCrit,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(sCurCrit,xmldoc) then
msgbox "xmldoc2"
fillList(xmldoc)
end if
else
msgbox "xmldoc3"
fillList xmldoc
end if
end if
End Sub
-->
</SCRIPT>
<SCRIPT LANGUAGE=vbscript>
<!--
Sub ClearList
lstTitles.innerHTML=""
End Sub
Sub fillList(pxmlDoc)
'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.documentelement.childnodes
set oOption = document.createElement("OPTION")
oOption.value = oNode.GetAttribute("orderid")
oOption.text = oNode.GetAttribute("customerid") & _
" - " & oNode.GetAttribute("orderid")
lstTitles.options.add oOption
next
end sub
Function RetrieveData(psCrit, pxmlDoc)
dim oHTTP,xPE,bStatus, sUrl
RetrieveData = true
set oHTTP = CreateObject("Microsoft.XMLHTTP")
set pxmlDoc = CreateObject("Microsoft.XMLDOM")
sUrl = "ListDemo_server.asp?P1=" & pscrit & "&User=" &
txtUser.value & _
"&Server=" & txtServer.value & "&PWD=" & txtPwd.value
oHTTP.open "GET",sUrl, false
oHTTP.send
bStatus= pxmlDoc.loadXML(oHTTP.responsetext )
if bStatus = false then
Set xPE = pxmlDoc.parseError
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,,"Retrieving Data"
RetrieveData=false
end if
set oHTTP = nothing
end function
-->
</SCRIPT>
</HEAD>
<BODY bgColor=lightgrey topMargin=2 leftMargin=2>
<DIV id=elHeading><STRONG><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><SELECT id=lstTitles style="VISIBILITY:
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=links.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
.