WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #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
  #2 (permalink)  
Old 10-22-2004, 01:25 AM
dr.p dr.p is offline
WebProWorld New Member
 

Join Date: Oct 2004
Location: sb in us
Posts: 12
dr.p RepRank 0
Default

Well, you've got:

Code:
For menuLoop = 1 to ScriptLoop
and then:

Code:
If MenuLoop = submenuLoop then
... "MenuLoop" should probably be "menuLoop"? Or is ASP not case sensitive with the var names?

Either way, where is ScriptLoop set and what is it set to? Since that's your loop limit, that part is important.
__________________
"Oh Peter. You're what the Spaniards call El Terrible" ~ Cleveland of "Family Guy"
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: help, javascript, programming



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Search Engine Friendly URLs by vBSEO 3.0.0