Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript OnChange Help required

Status
Not open for further replies.

Sunil606

Programmer
Dec 8, 2003
27
GB
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=&quot;connectionstring.asp&quot; --> <!--'Server side include used to hold the database connection details. Page 481 in Beginning ASP 3.0 book-->

<!-- METADATA TYPE=&quot;typelib&quot; '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=&quot;C:\Program Files\Common Files\System\ado\msado15.dll&quot; -->

<html>
<head></head>
<title>Test</title>
<body>

<%
Dim strRoomNo
Dim strSQL
Dim strSQL1
strRoomNo = Request.Form(&quot;Location&quot;)
'Response.Write strRoomNo


Dim strConnect
Dim objRS ' Declare variable for recordset object
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;) 'Create the the recordset object
strSQL = &quot;SELECT Computers.SerialNo FROM Computers WHERE Computers.RoomNo = '&quot; & strRoomNo & &quot;';&quot;
objRS.Open strSQL, strConnect

Dim objRS1 ' Declare variable for recordset object
Set objRS1 = Server.CreateObject(&quot;ADODB.Recordset&quot;) 'Create the the recordset object
strSQL = &quot;SELECT Computers.SerialNo FROM Computers WHERE Computers.RoomNo = '&quot; & strRoomNo & &quot;';&quot;
objRS1.Open strSQL1, strConnect



%>

<SELECT NAME=&quot;Location&quot; SIZE=&quot;1&quot;>

<%
Do While NOt objRS.EOF
Response.Write &quot;<OPTION VALUE='&quot; & objRS(&quot;RoomNo&quot;) & &quot;'>&quot; & &quot;<BR>&quot;
Response.Write objRS(&quot;RoomNo&quot;) & &quot;</OPTION>&quot; & &quot;<BR>&quot;
objRS.MoveNext
Loop
objRS.Close
Set objRS = Nothing
%>
</SELECT></B><BR><BR>




<SELECT NAME=&quot;SerialNo&quot; SIZE=&quot;1&quot;>

<%
Do While NOt objRS1.EOF
Response.Write &quot;<OPTION VALUE='&quot; & objRS1(&quot;SerialNo&quot;) & &quot;'>&quot; & &quot;<BR>&quot;
Response.Write objRS1(&quot;SerialNo&quot;) & &quot;</OPTION>&quot; & &quot;<BR>&quot;
objRS1.MoveNext
Loop
objRS1.Close
Set objRS1 = Nothing
%>
</SELECT></B><BR><BR>
</body>
</html>
 
i looked at that, but that is hard coded, i want it dynamic, so on onChange, it executes the 2nd SQL statement
 
Then you would have to use a hidden Frame/IFrame or an XML connection that would interact with the server to retrieve the data.
 
If you like the Javascript approach outlined in the link in my previous post, you can still use it with dynamic data by simply using an ASP page to generate the Javascript lines that you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top