View Single Post
  #1 (permalink)  
Old 10-21-2004, 04:02 PM
vharris vharris is offline
WebProWorld New Member
 

Join Date: Jul 2003
Location: Houston. Texas
Posts: 15
vharris RepRank 0
Default Javascript Programming Help

Hello,

I'm trying to create a havascript pop_up window, that categories and subcategories from the database using ASP script. How can I modify the following script so that more then one sub categor is shown. Currently, it shows the first and second categories.

<%
Response.write "<Script language='JavaScript'>" & vbcrlf
Response.write "function SubMenu(Cell){"& vbcrlf
Response.write "switch (Cell)"& vbcrlf & "{"& vbcrlf
Response.Write "case S0:{"& vbcrlf
For menuLoop = 1 to ScriptLoop
Response.write "S" & menuLoop & ".style.display = " & "'" & "none" & "'" & vbcrlf
Next
Response.write "}"& vbcrlf
Response.write "break" & vbcrlf
For menuLoop = 1 to ScriptLoop
Response.Write "case S" & menuLoop & ":{"& vbcrlf
For submenuLoop = 1 to ScriptLoop
If MenuLoop = submenuLoop then
Response.write "S" & submenuLoop & ".style.display = ''" & vbcrlf
Else
Response.write "S" & submenuLoop & ".style.display = " & "'" & "none" & "'" & vbcrlf
End If
Next
Response.write "}"& vbcrlf
Response.write "break" & vbcrlf

Next
Response.write "}"& vbcrlf
Response.write "}"& vbcrlf
Response.write "</Script>" & vbcrlf
%>

Here is the code that process the script above.
<%
SQLMenu= "Select * From categories Where idParentCategory=1 and idCategory>1 and iBTOhide=0 Order By priority"
Set rsMenu = Server.CreateObject( "ADODB.Recordset" )
rsMenu.ActiveConnection = DBCon
rsMenu.CursorType = adOpenStatic
rsMenu.Open( SQLMenu )
ScriptLoop = rsMenu.RecordCount
%>
<%
While Not rsMenu.EOF

IDCategory1=rsMenu("idcategory")
CatDesc1=rsMenu("categorydesc")

%>
<%LoopCounter = LoopCounter + 1%>
<table id="T<%=LoopCounter%>" border="0" width="180" style="position: absolute; left: 10; top: <%=LoopCounter*20%>; z-index: 1" onMouseOver="SubMenu(S<%=LoopCounter%>)" class="Menu">
<tr>
<td width="100%"><%=rsMenu( "categorydesc" )%></td>
</tr>
</table>
<table id="S<%=LoopCounter%>" class="submenu" border="0" cellpadding="3" cellspacing="1" width="180" style="display: none; position: absolute; left: 189px; top: <%=(LoopCounter*20)+ 5%>; z-index: 2; top: 27px">
<%

SQLSubMenu= "Select idcategory, idparentcategory, categorydesc From categories Where idparentcategory=" & IDCategory1 & " and idCategory>1 Order By priority"
Set rsSubMenu = DBCon.Execute(SQLSubMenu)
While Not rsSubMenu.EOF

IDCategory2=rsSubMenu("idcategory")
CatDesc2=rsSubMenu("categorydesc")

%> <%SubLoopCounter = SubLoopCounter + 1%>
<tr>
<td id="SB<%=LoopCounter & SubLoopCounter%>" onMouseOver=Swap(this) onMouseOut=Swap(this) width="100%" onClick="NavTo(&quot;<%=rsSubMenu( "categorydesc" )%>&quot;)">
<%=rsSubMenu( "categorydesc" )%> </td>
</tr>
<%rsSubMenu.MoveNext%>
<%Wend%>
<%SubLoopCounter=0%>
</table>


<table id="S<%=SubLoopCounter2%>" class="submenu" border="0" cellpadding="3" cellspacing="1" width="180" style="display: none; position: absolute; left: 368px; top: <%=(SubLoopCounter*20)+ 5%>; z-index: 3; top: 44px" >
<%

SQLSubMenu2= "Select idcategory, idparentcategory, categorydesc From categories Where idparentcategory=" & IDCategory2 & " and idCategory>1 Order By priority"
Set rsSubMenu2 = DBCon.Execute(SQLSubMenu)
ScriptLoop3 = rsSubMenu.RecordCount
While Not rsSubMenu2.EOF

IDCategory3=rsSubMenu2("idCategory")
CatDesc3=rsSubMenu2("categorydesc")

%> <%SubLoopCounter2 = SubLoopCounter2 + 1%>
<tr>
<td id="SB<%=LoopCounter&SubLoopCounter & SubLoopCounter2%>" onMouseOver="SubMenu(S<%=LoopCounter%>)" class="Menu" >
<%=rsSubMenu2( "categorydesc" )%> </td>
</tr>
<%rsSubMenu2.MoveNext%>
<%Wend%>
<%SubLoopCounter2=0%>
</table>

<table id="S<%=SubLoopCounter3%>" class="submenu" border="0" cellpadding="3" cellspacing="1" width="180" style="display: none; position: absolute; left: 549px; top: <%=(SubLoopCounter*20)+ 5%>; z-index: 4; top: 63px">
<%

SQLSubMenu3= "Select idcategory, idparentcategory, categorydesc From categories Where idparentcategory=" & IDCategory3 & " and idCategory>1 Order By priority"
Set rsSubMenu3 = DBCon.Execute(SQLSubMenu)
While Not rsSubMenu2.EOF

IDCategory3=rsSubMenu3("idCategory")
CatDesc3=rsSubMenu3("categorydesc")

%> <%SubLoopCounter3 = SubLoopCounter3 + 1%>
<tr>
<td id="S<%=LoopCounter&SubLoopCounter & SubLoopCounter2&SubLoopCounter3%>" onMouseOver=Swap(this) onMouseOut=Swap(this) width="100%" onClick="NavTo(&quot;<%=rsSubMenu3( "categorydesc" )%>&quot;)">
<%=rsSubMenu3( "categorydesc" )%> </td>
</tr>
<%rsSubMenu3.MoveNext%>
<%Wend%>
<%SubLoopCounter3=0%>
</table>


<%rsMenu.MoveNext%>
<%Wend%>

</body>
__________________
Web Developer/Designer
vgharris0@hotmail.com
Reply With Quote