PDA

View Full Version : dynamic drop down list


derick_loo
06-09-2003, 12:22 AM
I'm new in ASP. I m in design a page which contain 3 drop down list. But i can do it dynamic. It means when i choose the first drop down list, the second list will change to the particular data belong to the first drop down list, when i choose 2nd drop down, 3rd drop down will change to particular data belong to 2nd drop down. And all the data is retrieve from database. I face very big problem on this really need help. this is urgent.
Thanks a lot first!

amir
06-09-2003, 11:07 AM
can we refresh the page or do we need to do this on the client side ?

af11k
06-09-2003, 12:18 PM
I use Matt's script....

http://www.mattkruse.com/javascript/dynamicoptionlist/

It works great...
HTH

derick_loo
06-09-2003, 08:44 PM
Actually My page is let user select and then they will click a submit button and will link to another page.

derick_loo
06-09-2003, 09:41 PM
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

can told me what about error means

Thanks

af11k
06-09-2003, 10:12 PM
http://www.adopenstatic.com/faq/80040e10.asp

cebuWebGuy
07-02-2003, 10:54 PM
Originally posted by af11k
http://www.adopenstatic.com/faq/80040e10.asp

email me the table structure with the accompanying sample data, and ill write the code for you.... :-)


i have solve this problem in my previous assignment.:-)

af11k
07-02-2003, 11:26 PM
have you solved the problem?

derick_loo
07-03-2003, 11:06 PM
yup, i solve the drop down list problem. But my project is stop already. anyway, thanks a lot. I learn new thing from you all.

af11k
07-03-2003, 11:09 PM
can you tell us how you solved it, this way we all can learn something...don't you think?

derick_loo
07-04-2003, 12:39 AM
below is the code for my drop down list:


<%
Response.Buffer=true
Response.AddHeader "cache-control", "private"
Response.AddHeader "pragma", "no-cache"
Response.ExpiresAbsolute = #January 1, 1990 00:00:01#
Response.Expires=Now()-1
Response.AddHeader "Cache-Control", "must-revalidate"
Response.AddHeader "Cache-Control", "no-cache"
strScriptName = Request.ServerVariables("SCRIPT_NAME")
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hexagon Tatsuno HelpDesk</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<%

Dim conn
Dim rs
Dim strconn
Dim DBQValue
Dim rs2
Dim rs3

Session("DataConn_ConnectionString") = _
"DSN=EXTRANET;database=EXTRANET;uid=sa;pwd=saa"

strconn= Session("DataConn_ConnectionString")
set conn= server.createobject("adodb.connection")
set rs= server.createobject("adodb.recordset")
set rs2= server.createobject("adodb.recordset")
set rs3= server.createobject("adodb.recordset")
conn.open strconn
strsql="SELECT * FROM Dept"
rs.open strsql, conn, 2, 2

sql="SELECT * FROM Area WHERE ((Area.DeptID)='" & request("one") & "');"
rs2.open sql, conn, 2, 2

str="Select * from Corporate where ((Corporate.AreaCode)='"& request("d2") &"');"
rs3.open str, conn, 2,2
%>


<script language="vbscript">
sub submitthis
form1.submit
end sub
</script>


<body>
<table width="100%" border="0" cellspacing="0">
<tr>
<td><img src="Image/hexagonhelpdesklogo.jpg" width="227" height="73"></td>
</tr>
<tr>
<td><!--#include virtual="frame2.asp"--></td>
</tr>

<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><font size="2" face="Courier New, Courier, mono">Please Choose Region,
State and Station</font></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0">
<tr>
<td width="10%" rowspan="5"><img src="Image/hexagon3Dlogo.jpg" width="64" height="64"></td>
<td width="11%"><font size="3" face="Courier New, Courier, mono"><strong>Region
</strong></font></td>
<td width="2%"><font size="3" face="Courier New, Courier, mono"><strong>:</strong></font></td>
<td width="27%"><form ACTION="hex_choose.asp" METHOD="POST" NAME="form1" >
<p><select ONCHANGE="submitthis" SIZE="1" NAME="one">
<option value="none">-- choose a Region--</option>
<% Do While Not rs.EOF %><option value="<% = rs("DeptID") %>">
<% = rs("Deptname")%><% rs.movenext %><% loop %> </select> <br>
</p>
</form></td>

<td width="9%">&nbsp;</td>
<td width="41%">&nbsp;</td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td><strong><font face="Courier New, Courier, mono">State </font></strong></td>
<td><strong><font face="Courier New, Courier, mono">:</font></strong></td>
<td><form ACTION="hex_choose.asp" METHOD="POST" NAME="form2" >
<input type="hidden" name="one" value="<%= request("one") %>">
<p><select name="d2" size="1">
<OPTION Value="NONE">-- choose a State--</option>
<% Do While Not rs2.EOF %> <option value="<% = rs2("AreaCode") %>"><% = rs2("AreaDescription") %></option>
<% rs2.movenext %><% loop %> </select><br>

</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td><input type="submit" value="Display Data"></form></td>
</tr>


<tr>
<%if request("d2")<>"" then %>
<table name="submit" width="71%" border="1" align="center" bordercolor="#ccccff"cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#6699FF"><div align="center"><font size="2" face="Courier New, Courier, mono"><font color="#FFFFFF">Company Name</font></font></div></td>
<td bgcolor="#6699FF"><div align="center"><font color="#FFFFFF" size="2" face="Courier New, Courier, mono">Add</font></div></td>
<td bgcolor="#6699FF"><div align="center"><font color="#FFFFFF" size="2" face="Courier New, Courier, mono">Tel</font></div></td>
<td bgcolor="#6699FF"><div align="center"><font color="#FFFFFF" size="2" face="Courier New, Courier, mono">Fax</font></div></td>
<td bgcolor="#6699FF"><div align="center"><font color="#FFFFFF" size="2" face="Courier New, Courier, mono">EMail</font></div></td>
<td bgcolor="#6699FF"><div align="center"><font color="#FFFFFF" size="2" face="Courier New, Courier, mono">Contact Person</font></div></td>

</tr>
<%while not rs3.eof%>
<tr>
<td><a href="d_asset_detail.asp"><font size="2" face="Courier New, Courier, mono"><%=rs3("Companyname")%>&nbsp</font></a></td>
<td><font size="2" face="Courier New, Courier, mono"><%=rs3("Address")%>&nbsp</font></td>
<td><font size="2" face="Courier New, Courier, mono"><%=rs3("Tel")%>&nbsp</font></td>
<td><font size="2" face="Courier New, Courier, mono"><%=rs3("Fax")%>&nbsp</font></td>
<td><font size="2" face="Courier New, Courier, mono"><%=rs3("EMail")%>&nbsp</font></td>
<td><font size="2" face="Courier New, Courier, mono"><%=rs3("Contact")%>&nbsp</font></td>
</tr>

<% rs3.movenext
wend
%>

</tr>
</table>

<%
end if
rs3.close
set rs3 = nothing

rs2.close
set rs2 = nothing
rs.close
conn.close
set rs = nothing
set conn = nothing

%>


</body>
</html>