Hi,
I have written this asp code but feel that some javascript is required to do what i would like to do. I have this ASP page which has some list boxes. As the code shows below, I would like to know how it is possible to get a user to select the location of a room and after they have done that I would like another list box to appear with all the serial nos of computers in the room that they have chosen. At the moment it works but incorrectly as I would have to submit the form to itself for the form to work. It would be nice to get these details with submitting the form. If anyone can help me out with this problem i would appreciate it a lot!!
<!--'Code used and adapted from Beginning ASP 3.0 & Beginning ASP Databases -->
<!--'Code used and adapted from Beginning ASP Databases on page 162 -->
<!--#include file="connectionstring.asp" --> <!--'Server side include used to hold the database connection details. Page 481 in Beginning ASP 3.0 book-->
<!-- METADATA TYPE="typelib" 'This makes the ADO constants available without having to define them as constants. This information has been taken from page 519 of Beginning ASP 3.0
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<html>
<head></head>
<title>Test</title>
<body>
<%
Dim strRoomNo
Dim strSQL
Dim strSQL1
strRoomNo = Request.Form("Location"
'Response.Write strRoomNo
Dim strConnect
Dim objRS ' Declare variable for recordset object
Set objRS = Server.CreateObject("ADODB.Recordset"
'Create the the recordset object
strSQL = "SELECT Computers.SerialNo FROM Computers WHERE Computers.RoomNo = '" & strRoomNo & "';"
objRS.Open strSQL, strConnect
Dim objRS1 ' Declare variable for recordset object
Set objRS1 = Server.CreateObject("ADODB.Recordset"
'Create the the recordset object
strSQL = "SELECT Computers.SerialNo FROM Computers WHERE Computers.RoomNo = '" & strRoomNo & "';"
objRS1.Open strSQL1, strConnect
%>
<SELECT NAME="Location" SIZE="1">
<%
Do While NOt objRS.EOF
Response.Write "<OPTION VALUE='" & objRS("RoomNo"
& "'>" & "<BR>"
Response.Write objRS("RoomNo"
& "</OPTION>" & "<BR>"
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
%>
</SELECT></B><BR><BR>
<SELECT NAME="SerialNo" SIZE="1">
<%
Do While NOt objRS1.EOF
Response.Write "<OPTION VALUE='" & objRS1("SerialNo"
& "'>" & "<BR>"
Response.Write objRS1("SerialNo"
& "</OPTION>" & "<BR>"
objRS1.MoveNext
Loop
objRS1.Close
Set objRS1 = Nothing
%>
</SELECT></B><BR><BR>
</body>
</html>
I have written this asp code but feel that some javascript is required to do what i would like to do. I have this ASP page which has some list boxes. As the code shows below, I would like to know how it is possible to get a user to select the location of a room and after they have done that I would like another list box to appear with all the serial nos of computers in the room that they have chosen. At the moment it works but incorrectly as I would have to submit the form to itself for the form to work. It would be nice to get these details with submitting the form. If anyone can help me out with this problem i would appreciate it a lot!!
<!--'Code used and adapted from Beginning ASP 3.0 & Beginning ASP Databases -->
<!--'Code used and adapted from Beginning ASP Databases on page 162 -->
<!--#include file="connectionstring.asp" --> <!--'Server side include used to hold the database connection details. Page 481 in Beginning ASP 3.0 book-->
<!-- METADATA TYPE="typelib" 'This makes the ADO constants available without having to define them as constants. This information has been taken from page 519 of Beginning ASP 3.0
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<html>
<head></head>
<title>Test</title>
<body>
<%
Dim strRoomNo
Dim strSQL
Dim strSQL1
strRoomNo = Request.Form("Location"
'Response.Write strRoomNo
Dim strConnect
Dim objRS ' Declare variable for recordset object
Set objRS = Server.CreateObject("ADODB.Recordset"
strSQL = "SELECT Computers.SerialNo FROM Computers WHERE Computers.RoomNo = '" & strRoomNo & "';"
objRS.Open strSQL, strConnect
Dim objRS1 ' Declare variable for recordset object
Set objRS1 = Server.CreateObject("ADODB.Recordset"
strSQL = "SELECT Computers.SerialNo FROM Computers WHERE Computers.RoomNo = '" & strRoomNo & "';"
objRS1.Open strSQL1, strConnect
%>
<SELECT NAME="Location" SIZE="1">
<%
Do While NOt objRS.EOF
Response.Write "<OPTION VALUE='" & objRS("RoomNo"
Response.Write objRS("RoomNo"
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
%>
</SELECT></B><BR><BR>
<SELECT NAME="SerialNo" SIZE="1">
<%
Do While NOt objRS1.EOF
Response.Write "<OPTION VALUE='" & objRS1("SerialNo"
Response.Write objRS1("SerialNo"
objRS1.MoveNext
Loop
objRS1.Close
Set objRS1 = Nothing
%>
</SELECT></B><BR><BR>
</body>
</html>