It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming ASP & ASP.NET Forum

Expandable and collapsable menus in ASP, no JavaScript

Expandable and collapsable menus in ASP, no JavaScript

Postby tallgal on Fri Oct 08, 2004 9:43 am

I have the following code, which is supposed to output all phases for project 38. Each phase has a number of actions, meetings and services associated with it.

What I want to happen is, initially, the user sees the list of phases. Clicking on a phase name 'expands' to reveal the total number of actions, meetings or services within that phase. When the user then clicks on, say the count of actions, the page then 'expands' again to reveal a list of actions, form which the user can edit or delete. :D

This should be a straightforward check for the prescence of a URL variable, if present expand, else don't. The problem here is that while the code 'works' i.e. it does all the expanding I want it do to, there are two problems:-

1) Clicking on one phase expands all phases, I am only interested in the one i clicked on
2) Clicking on the count of phases, meetings or services expands the list for as many phases are present. So if i have 10 phases, I click on phase 1, all 10 expand and show THE SAME information. If phase 1 has 3 actions and I click on that, All 10 will reveal the details for the 3 actions. I guess this is happening because I am doing all the processing within the recordset. :cry:

Some of you might ask why I don't simply translate form JaveScript, well it is because I am not that good with javaScript either!!! But I have done something similar in ColdFusion, using <cfloop query="query name"> and it works fine.

So what's different in ASP?

Thanks.

Nicky


<!-- #include file="../includes/connection.asp" -->
<!-- #include file="../includes/pathtrigger.asp" -->

<%
path="../"

session("userid") = 2
session("team_id")= 1
session("user") = "Test Person"

session("where") = "Projects"
session("mypart") = "Details"


dim SL, SL2, SL3, projid
dim managerRS, teamRS
dim is_project_manager, is_account_manager, is_team_member

is_project_manager=0
is_team_member=0
is_account_manager=0
projid=38

set managerRS=Server.CreateObject("adodb.recordset")
set teamRS=Server.CreateObject("adodb.recordset")


'who is the user with respect to this project?
SL="SELECT a.user_id FROM project_managers a, projects b WHERE a.project_id=b.project_id and b.project_id=" & projid
managerRS.open SL,objConn
while not managerRS.EOF
if Instr(managerRS("user_id"),CINT(session("userid"))) > 0 then is_project_manager=1 end if
managerRS.MoveNext
wend
managerRS.close
set managerRS=nothing

'is the user a team member
SL2="SELECT a.team_id FROM project_teams a, projects b WHERE a.project_id=b.project_id AND b.project_id=" & projid
teamRS.open SL2,objConn
while not teamRS.EOF
if Instr(teamRS("team_id"),CINT(session("team_id"))) > 0 then is_team_member=1 end if
teamRS.MoveNext
wend
teamRS.close
set teamRS=nothing


dim phaseRS, phaseCount, actionRS, ACDocRS, MtRs, MtCount, SQL, ActionCount, MtDocsRS, SrCount, serviceRS


set projRS=Server.CreateObject("adodb.recordset")
SQL="SELECT project_title FROM projects WHERE project_id=" & projid

projRS.open SQL,objConn

while not projRS.eof
pname=projRS("project_title")
projRS.MoveNext
wend
projRS.close
set projRS=nothing

'Phases
set phaseRS=Server.CreateObject("ADODB.Recordset")

SQL="SELECT * FROM project_phases WHERE project_id=" & projid
phaseRS.open SQL,objConn
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Projects</title>
<link rel="stylesheet" type="text/css" href="../styles/sitewide.css">
</head>

<body class="body" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<table align="left" width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td valign="top" height="25">
<!--- header --->
<table align="left" width="100%" border="0">
<!-- #include file="../includes/header.asp" -->
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tR>
<td colspan="3" class="smallheader" align="center"><%=pname%></td>
</tr>
<!--- main content --->
<tr>
<td colspan="3" align="left">
<table align="center" width="100%" border="0" cellpadding="4" cellspacing="1">
<tR class="sectionheader">
<td align="left">Phase name</td>
<tD align="left">Actions</td>
</tr>
<%while not phaseRS.eof
'do the counts for actions, services and meetings in here

'Actions
set actionRS=Server.CreateObject("ADODB.Recordset")
SQL="SELECT count(a.action_id) as acount FROM actions a, project_phases b WHERE a.phase_id=b.phase_id AND b.phase_id=" & phaseRS("phase_id")

actionRS.open SQL,objConn

while not actionRS.eof
ActionCount=actionRS("acount")
actionRS.MoveNext
wend
actionRS.close
set actionRS=nothing

'Meetings
set MtRS=Server.CreateObject("ADODB.Recordset")
SQL="SELECT count(a.meeting_id) as acount FROM meetings a, project_phases b WHERE a.phase_id=b.phase_id AND b.phase_id=" & phaseRS("phase_id")

MtRS.open SQL,objConn

while not MtRS.eof
MtCount=MtRS("acount")
MtRS.MoveNext
wend
MtRS.close
set MtRS=nothing

'services
set serviceRS=Server.CreateObject("ADODB.Recordset")
SQL="SELECT count(a.service_id) as srcount FROM services a, project_phases b WHERE a.phase_id=b.phase_id AND b.phase_id=" & phaseRS("phase_id")

serviceRS.open SQL,objConn
while not serviceRS.eof
SrCount=serviceRS("srcount")
serviceRS.MoveNext
wend
serviceRS.close
set serviceRS=nothing%>

<tR>
<td align="left">
<%if request.querystring("exp1") = "yes" then%>
+&nbsp;<a href="test_module.asp?phase_id=<%=phaseRS("phase_id")%>&exp1=no"><%=phaseRS("phase_name")%></a>
<%else%>
<a href="test_module.asp?phase_id=<%=phaseRS("phase_id")%>&exp1=yes"><%=phaseRS("phase_name")%></a>
<%end if%>
</td>

<tD align="left">
<%if is_project_manager = 1 OR is_team_member = 1 then%>
<a href="">View</a> &nbsp;|&nbsp;
<a href="">Edit</a> &nbsp;|&nbsp;
<a href="">Delete</a>
<%else%>
<font color="#808080">
View &nbsp;|&nbsp; Edit &nbsp;|&nbsp; Delete
</font>
<%end if%>
</td>
</tr>

<%if request.querystring("exp1") = "yes" then%>
<!--- now do the interesting stuff --->
<tR>
<td align="left">
<%if request.querystring("exp2") = "no" then%>
+&nbsp;<a href="test_module.asp?phase_id=<%=request.querystring("phase_id")%>&exp1=yes&exp2=no"><%=ActionCount%> action<%if ActionCount > 1 then%>s<%end if%></a>

<%else%>
<a href="test_module.asp?phase_id=<%=request.querystring("phase_id")%>&exp1=yes&exp2=yes"><%=ActionCount%> action<%if ActionCount > 1 then%>s<%end if%></a>

<%end if%>
</td>
</tR>

<!--- the actions themselves --->
<%if request.querystring("exp1") = "yes" AND request.querystring("exp2") = "yes" then
'get details of these actions

set actionRS=Server.CreateObject("ADODB.Recordset")

SQL="SELECT action_id, action_name FROM actions WHERE phase_id=" & request.querystring("phase_id")
'response.write SQL & "<br>"
actionRS.open SQL,objConn
while not actionRS.eof%>
<tR>
<td align="left" colspan="2"><%=actionRS("action_name")%></td>
<tD align="left">
<%if is_project_manager = 1 OR is_team_member = 1 then%>
<a href="">View</a> &nbsp;|&nbsp;
<a href="">Edit</a> &nbsp;|&nbsp;
<a href="">Delete</a>
<%else%>
<font color="#808080">
View &nbsp;|&nbsp; Edit &nbsp;|&nbsp; Delete
</font>
<%end if%>
</td>
</tR>
<%actionRS.MoveNext
wend
actionRS.close
set actionRS=nothing
END IF%>

<tR>
<td align="left" colspan="2">
<%if request.querystring("exp3") = "yes" then%>
+&nbsp;<a href="test_module.asp?phase_id=<%=request.querystring("phase_id")%>&exp1=yes&exp3=no"><%=MtCount%> meeting<%if MtCount > 1 then%>s<%end if%></a>

<%else%>
<a href="test_module.asp?phase_id=<%=request.querystring("phase_id")%>&exp1=yes&exp3=yes"><%=MtCount%> meeting<%if MtCount > 1 then%>s<%end if%></a>

<%end if%>
</td>
</tR>
<!--- the MEETINGS themselves --->
<%if request.querystring("exp1") = "yes" AND request.querystring("exp3") = "yes" then
'get details of these meetings
set MtRS=Server.CreateObject("ADODB.Recordset")
SQL="SELECT * FROM MEETINGS WHERE phase_id=" & request.querystring("phase_id")
response.write SQL & "<br>"
MtRS.open SQL,objConn
while not MtRS.eof%>
<tR>
<td align="left" colspan="2"><%=MtRS("meeting_name")%></td>
<tD align="left">
<%if is_project_manager = 1 OR is_team_member = 1 then%>
<a href="">View</a> &nbsp;|&nbsp;
<a href="">Edit</a> &nbsp;|&nbsp;
<a href="">Delete</a>
<%else%>
<font color="#808080">
View &nbsp;|&nbsp; Edit &nbsp;|&nbsp; Delete
</font>
<%end if%>
</td>
</tR>
<%MtRS.MoveNext
wend
MtRS.close
set MtRS=nothing
END IF%>

<tR>
<td align="left" colspan="2">
<%if request.querystring("exp4") = "yes" then%>
+&nbsp;<a href="test_module.asp?phase_id=<%=request.querystring("phase_id")%>&exp1=yes&exp4=no"><%=SrCount%> service<%if SrCount > 1 then%>s<%end if%></a>

<%else%>
<a href="test_module.asp?phase_id=<%=request.querystring("phase_id")%>&exp1=yes&exp4=yes"><%=SrCount%> service<%if SrCount > 1 then%>s<%end if%></a>

<%end if%>
</td>
</tR>
<!--- the services themselves --->
<%if request.querystring("exp1") = "yes" AND request.querystring("exp4") = "yes" then
'get details of these services
set serviceRS=Server.CreateObject("ADODB.Recordset")
'response.write SQL & "<br>"
SQL="SELECT DISTINCT service_id, service_name FROM services WHERE phase_id=" & request.querystring("phase_id")
serviceRS.open SQL,objConn

while not serviceRS.eof%>
<tR>
<td align="left" colspan="2"><%=serviceRS("service_name")%></td>
<tD align="left">
<%if is_project_manager = 1 OR is_team_member = 1 then%>
<a href="">View</a> &nbsp;|&nbsp;
<a href="">Edit</a> &nbsp;|&nbsp;
<a href="">Delete</a>
<%else%>
<font color="#808080">
View &nbsp;|&nbsp; Edit &nbsp;|&nbsp; Delete
</font>
<%end if%>
</td>
</tR>

<%serviceRS.MoveNext
wend
serviceRS.close
set serviceRS=nothing
END IF%>

<%END IF
phaseRS.MoveNext
wend
phaseRS.close
set phaseRS=nothing%>
</table>
</tD>
</tr>
</table>
</tD>
</tR>
</table>
</body>
</html>
tallgal
 
Posts: 2
Joined: Fri Oct 08, 2004 9:29 am

Postby Malcolm on Sat Oct 09, 2004 1:10 am

Do you have a copy of the code online somewhere on the net, I'm running on Linux right now so firing up an ASP script isn't gonna happen anytime soon ;)
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby tallgal on Sat Oct 09, 2004 10:52 am

No, I don't, that's why I posted it in my message.
tallgal
 
Posts: 2
Joined: Fri Oct 08, 2004 9:29 am


Who is online

Users browsing this forum: No registered users and 0 guests