I have read in these forums that VBScript can be either client or server side - Since Netscape cannot handle VBScript that is client-side, how do I make the code run at the server?
Here is the page I need to work in IE or Netscape
It currently works great in IE....
( The VBScript code is from Adrian Forbes and I have included it in a simple test page with values from a drop-down list populated from a database...)
-----------------------------------------------------------
<%@ Language=VBScript %>
<html>
<body>
<div align="center" >
<%
Dim objDC, objRS
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection"
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
'Code to connect to Oracle Warehouse
objDC.Open "Provider=MSDAORA.1;Password=*****;User ID=*****;Data Source=whs1"
SqlStrEmp = "Select distinct empl_nm,empl_nbr empnbr from warehouse.hr_public order by empl_nm"
Set RS1 = objDC.Execute(SqlStrEmp)
arrEmpData = RS1.GetRows()
RS1.Close
Set RS1 = Nothing
objDC.Close
Set objDC = Nothing
iRecFirstEmp = LBound(arrEmpData, 2)
iRecLastEmp = UBound(arrEmpData, 2)
iFieldFirstEmp = LBound(arrEmpData, 1)
iFieldLastEmp = UBound(arrEmpData, 1)
%>
<!-- Author: Adrian Forbes -->
<form name=frmTest METHOD="POST" ACTION="SeeForm.asp">
<select size="1" name=prompt0 ID=cboTest onKeyPress="return SelectText();">
<%
' Loop through the records (second dimension of the array)
For I = iRecFirstEmp To iRecLastEmp
' Continue until we get to the end of the recordset.
%>
<OPTION VALUE="<%=trim(arrEmpData(iFieldLastEmp,I)) %>"><%=trim(arrEmpData(iFieldFirstEmp,I)) %> </OPTION>
<%
' Get next record
Next ' I
%>
</SELECT>
</select>
<INPUT type="hidden" NAME="p1" Value="">
<INPUT type="submit" Value="Try It" >
</form>
</div>
<script type="text/vbscript" language="VBScript" runat="server">
dim sBuffer ' This var stores the buffer of letters typed
function SelectText
dim objSelect, i, iLen
SelectText = False ' We need to return False to disable the
' SELECT's built-in functionality which is to
' select the first OPTION that begins with the
' key you pressed
sBuffer = sBuffer & Chr(window.event.keyCode) ' The keyCode is the ASCII value of the key you pressed
' so turn that into a character and add it to the buffer
iLen = len(sBuffer) ' We will be using this length a lot so store it in a local var for speed
set objSelect = document.frmTest.cboTest ' Get a handle on the SELECT object
for i = 0 to objSelect.Options.length - 1 ' Loop through each OPTION
if strcomp(left(objSelect.Options(i).Text, iLen), sBuffer, 1) = 0 then ' Test if the OPTION's Text starts with
' document.all("BestMatch".innerText = objSelect.Options(i).Text
document.frmTest.p1.value = objSelect.Options(i).Text ' the same letters as the buffer
objSelect.SelectedIndex = i ' If it does we want to select it
exit function ' Then exit the function
end if
next
sBuffer = "" ' If the code gets this far there is nothing in the SELECT
' that matches the buffer so reset it allowing the user
' to type new letters
end function
</script>
</body>
</html>
--------------------------------------------------------
Thanks in advance for helping a newbie understand what's going on...
Here is the page I need to work in IE or Netscape
It currently works great in IE....
( The VBScript code is from Adrian Forbes and I have included it in a simple test page with values from a drop-down list populated from a database...)
-----------------------------------------------------------
<%@ Language=VBScript %>
<html>
<body>
<div align="center" >
<%
Dim objDC, objRS
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection"
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
'Code to connect to Oracle Warehouse
objDC.Open "Provider=MSDAORA.1;Password=*****;User ID=*****;Data Source=whs1"
SqlStrEmp = "Select distinct empl_nm,empl_nbr empnbr from warehouse.hr_public order by empl_nm"
Set RS1 = objDC.Execute(SqlStrEmp)
arrEmpData = RS1.GetRows()
RS1.Close
Set RS1 = Nothing
objDC.Close
Set objDC = Nothing
iRecFirstEmp = LBound(arrEmpData, 2)
iRecLastEmp = UBound(arrEmpData, 2)
iFieldFirstEmp = LBound(arrEmpData, 1)
iFieldLastEmp = UBound(arrEmpData, 1)
%>
<!-- Author: Adrian Forbes -->
<form name=frmTest METHOD="POST" ACTION="SeeForm.asp">
<select size="1" name=prompt0 ID=cboTest onKeyPress="return SelectText();">
<%
' Loop through the records (second dimension of the array)
For I = iRecFirstEmp To iRecLastEmp
' Continue until we get to the end of the recordset.
%>
<OPTION VALUE="<%=trim(arrEmpData(iFieldLastEmp,I)) %>"><%=trim(arrEmpData(iFieldFirstEmp,I)) %> </OPTION>
<%
' Get next record
Next ' I
%>
</SELECT>
</select>
<INPUT type="hidden" NAME="p1" Value="">
<INPUT type="submit" Value="Try It" >
</form>
</div>
<script type="text/vbscript" language="VBScript" runat="server">
dim sBuffer ' This var stores the buffer of letters typed
function SelectText
dim objSelect, i, iLen
SelectText = False ' We need to return False to disable the
' SELECT's built-in functionality which is to
' select the first OPTION that begins with the
' key you pressed
sBuffer = sBuffer & Chr(window.event.keyCode) ' The keyCode is the ASCII value of the key you pressed
' so turn that into a character and add it to the buffer
iLen = len(sBuffer) ' We will be using this length a lot so store it in a local var for speed
set objSelect = document.frmTest.cboTest ' Get a handle on the SELECT object
for i = 0 to objSelect.Options.length - 1 ' Loop through each OPTION
if strcomp(left(objSelect.Options(i).Text, iLen), sBuffer, 1) = 0 then ' Test if the OPTION's Text starts with
' document.all("BestMatch".innerText = objSelect.Options(i).Text
document.frmTest.p1.value = objSelect.Options(i).Text ' the same letters as the buffer
objSelect.SelectedIndex = i ' If it does we want to select it
exit function ' Then exit the function
end if
next
sBuffer = "" ' If the code gets this far there is nothing in the SELECT
' that matches the buffer so reset it allowing the user
' to type new letters
end function
</script>
</body>
</html>
--------------------------------------------------------
Thanks in advance for helping a newbie understand what's going on...