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!

Dynamic Database List boxes

Status
Not open for further replies.

Sunil606

Programmer
Dec 8, 2003
27
GB
Hi,

I have a ASP page which has a form with some dynamic list boxes generated from a database. What I would like to do is to write some asp code that will generate dynamically generate another list box after the user has made a selection from a previous one. Here is the code.






<%
Dim strConnect
Dim objRS ' Declare variable for recordset object
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;) 'Create the the recordset object
objRS.open &quot;Room&quot;, strConnect
objRS.MoveFirst

%>
<HTML>
<HEAD>


<TITLE>MHCHS - Report a fault</TITLE>
</HEAD>
<BODY BGCOLOR=&quot;#FFFF80&quot;>








<%


Response.write &quot;<A HREF=home.asp>Log out</A><BR>&quot;
End If
%>



<FORM ACTION = &quot;ProcessAddFault.asp&quot; METHOD = &quot;POST&quot;>



<P ALIGN=&quot;CENTER&quot;><b>Fault Reported by :<% =session(&quot;StaffName&quot;) %></B><BR></B>
<P ALIGN=&quot;CENTER&quot;><b>Email Address:<% =session(&quot;EmailAddress&quot;) %></B><BR></B>
<P ALIGN=&quot;CENTER&quot;><b>Type Of Fault&nbsp;&nbsp; </b><SELECT NAME =&quot;FaultType&quot; Size=&quot;1&quot;>
<OPTION SELECTED VALUE=&quot;Hardware&quot;>Hardware</OPTION>
<OPTION VALUE=&quot;Software&quot;>Software</OPTION>
<OPTION VALUE=&quot;Network&quot;>Network</OPTION>
<OPTION VALUE=&quot;Other&quot;>Other</OPTION>

'Code used and adapted from Beginning ASP Databases on page 162


</SELECT><p align=&quot;CENTER&quot;><b>Location&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </b>
<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>


' After the user has selected the room number I would like to show another drop down list box which shows all the serial nos of computers stored in that room. Does asp allow this or do i require some javascript?










<P ALIGN=&quot;CENTER&quot;><TextArea Name = &quot;Details&quot; COLS=50 ROWS= 10></TextArea><BR><BR>





<input type = &quot;Submit&quot; Value = &quot;Submit Fault&quot;></a><input type = &quot;Reset&quot; Value = &quot;Clear Form&quot;><BR>
<BR>

If anyone has any ideas could they please let me know






























</BODY>
</HTML>
 
one of these should get you going

How do I make dynamic listboxes? faq333-1498
Linked List Boxes without Reloading Page faq333-3656
Linked Listboxes - HOWTO? faq333-1507


_____________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top