Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1763
Number of posts: 4498

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Dropdown List problem Posted by jaisan on 21 Jun 2005 at 11:30 PM
Hi

i have 3 dropdown list 1 for College list 2nd for Department list and 3rd for Research or events. First i'm getting college name from database and filling it in 1st drop down list box. when i select the anyone of the college i want to fill that college departments in 2nd dropdown list box in same way when i select department i want to fill research/event for the selected college and department.

i have code but it not working properly

like this...

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="source.asp" -->

<%
dim rec
public cg_code
Set rec = Server.CreateObject("ADODB.Recordset")
rec.open "select * from college",con,2,2
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<script language="javascript">
function college_change()
{
window.location.href="archieve1.asp? fw=ls&cg_code="+document.form1.college.value
}

function dept_change()
{
alert(document.form1.college.value)
alert(document.form1.dept.value)
window.location.href="archieve1.asp?fw=ls&dp_code="+document.form1.dept.value&cg_code="+request.QueryString("cg_code")
}
</script>
</head>

<body>
<%if request.QueryString("fw")="ls" then %>
<table height="100%" width="100%" align="center">
<table width="80%" border="0" cellpadding="1" cellspacing="1" align="center">

<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td align="center" bgcolor="#6699FF"><font color="#FFFFFF"><b>Search<b></font></td></tr>
<tr><td align="center">&nbsp;</td></tr>

<tr><td><font color="#330099" size="2"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name of the College<b></font></td></tr>

<form name="form1" method="post" action="">
<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="college" onChange="college_change()" >
<option value="">---Select College---</option>
<% While (NOT Rec.EOF) %>
<option value="<%=(Rec.Fields("cg_code_in"))%>" selected=1><%=(Rec.Fields("cg_name_vc"))%></option>
<%
Rec.MoveNext()
Wend

If (Rec.CursorType > 0) Then
Rec.MoveFirst
Else
Rec.Requery
End If
%>
</select>
</td></tr>

<tr><td align="center">&nbsp;</td></tr>
<tr><td><font color="#330099" size="2"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name of the Department</b></font></td></tr>

<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="dept" onchange="dept_change()">
<option value="">------Select Department------</option>
<%
if not request.QueryString("cg_code")="" then
if rec.state=1 then rec.close
rec.open "select * from cg_dept where cg_code_in="& request.QueryString("cg_code")

While (NOT Rec.EOF)
%>
<option value="<%=(Rec.Fields("dp_code_in"))%>" selected=1><%=(Rec.Fields("dp_name_vc"))%></option>
<%
Rec.MoveNext()
Wend
end if

If (Rec.CursorType > 0) Then
Rec.MoveFirst
Else
Rec.Requery
End If
%>
</select>
</td></tr>

<tr><td align="center">&nbsp;</td></tr>
<tr><td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#330099" size="2">Event / Research </b></font></td></tr>

<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="event_type">
<option value=1>Event</option>
<option value=2>Research</option>
</select>
</td></tr>


<tr><td align="center">&nbsp;</td></tr>
<tr><td><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#330099" size="2">Title</b></font></td></tr>
<%
if not (request.QueryString("cg_code"))="" and not (request.QueryString("dp_code"))="" then
if rec.state=1 then rec.close
rec.open "select ne_code_in,ne_titile_vc from newsevents where cg_code_in="& request.QueryString("cg_code") & " and dp_code_in="& request.QueryString("dp_code")
response.Write("No.of records =>"& rec.recordcount)
%>

<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<select name="Title">
<%
while not rec.eof
%>
<option value="<%=rec.fields("ne_code_in")%>" selected> <%=rec.fields("ne_title_vc")%></option>
<%
rec.movenext
wend
end if
%>

</select>
</td></tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td align="center">
<input type="submit" value="Search">
</td>
</tr>
</form>

<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td></tr>
</table>
</table>
<% end if %>
</body>
</html>

<%
Rec.Close()
Set Rec = Nothing
%>


Thanks your help for me guys

Jai Sankar N





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.