Wrox Programmer Forums
|
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4
This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040
Please indicate which version of the book you are using when posting questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2003, 02:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It depends on what you're trying to accomplish.

The LoopCounter is useful in situations where you want to count; i.e. from 1 to 10 to create 10 items.

The Repeat Region is useful to repeat an item for each record in a recordset. In your case, the repeat region seems to make the most sense. It doesn't really matter where you use the code; the Recordset is defined before any HTML, so you can use it anywhere in your page. The problem with the Repeat Region is that it is a bit picky. It's difficult to repeat ASP code that writes out JavaScript in the <head> section of the page. It also adds too much <% and %> (though completely legal and correct), so you end up with slow code, so it's better to write some code yourself.

Anyway, your code below looks good; it will write out a list of links. To combine it with the menu code, try something like this:
Code:
<%
Dim rsProducts
Dim rsProducts_numRows

Set rsProducts = Server.CreateObject("ADODB.Recordset")
rsProducts.ActiveConnection = MM_connTestSite_STRING
rsProducts.Source = "SELECT Category, ID, Name, URL FROM Products ORDER BY Category ASC, Name ASC"
rsProducts.CursorType = 0
rsProducts.CursorLocation = 2
rsProducts.LockType = 1
rsProducts.Open()

rsProducts_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsProducts_numRows = rsProducts_numRows + Repeat1__numRows
%>

// Other HTML stuff here....

function mmLoadMenus() {
  if (window.mm_menu_1120161301_0) return;
  window.mm_menu_1120161301_0 = new Menu("root",300,18,"",12,
            "#000000","#FFFFFF","#CCCCCC","#000084",
            "left","middle",3,0,1000,-5,7,true,true,true,0,true,true);


<% 
While ((Repeat1__numRows <> 0) AND (NOT rsProducts.EOF))
  Response.Write("mm_menu_1120161301_0.addMenuItem(""" & _
    Replace(rsProducts("Name"), " ", "&nbsp;") & _
    """,""location='Item.asp?ID=" & rsProducts("ID") & "'"");")
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsProducts.MoveNext()
Wend
%>
  mm_menu_1120161301_0.hideOnMouseOut=true;
   mm_menu_1120161301_0.bgColor='#555555';
   mm_menu_1120161301_0.menuBorder=1;
   mm_menu_1120161301_0.menuLiteBgColor='#FFFFFF';
   mm_menu_1120161301_0.menuBorderBgColor='#777777';

mm_menu_1120161301_0.writeMenus();
} // mmLoadMenus()
Before you can run this page, you have to add a recordset called rsProducts to the page. This recordset needs at least a Name and a ID column, or you should modify the code accordingly.

Basically, this code loops through the recordset and writes out a menu item for each item in the recordset.

I have a column called Category in my recordset. If you want, you can loop through this code and write out a Main menu item for each new category. Then each product that belongs to that category gets its own sub menu item. I'll leave that to tomorrow's exercise ;)

The code also uses the Replace method to repalce spaces with their non-breaking space counterpart. If you don't do this, you'll end up with menu text over a couple of lines, instead of on one line.

Hope this helps and if not, please let me know.

Regards,


Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old December 2nd, 2003, 11:34 AM
Authorized User
 
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

greetings

thanks for the reply (and the code) - I thought I ought to let you know that I am still working on it, just have not had much time - also have had all sorts of strange permissions issues with new machine - now resolved :)

regards

steve

 
Old December 2nd, 2003, 01:32 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Good luck. You know where to find us when you need help..... ;)

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically generated dropdownlist csun ASP.NET 1.0 and 1.1 Basics 3 April 8th, 2008 07:38 AM
dynamically generated form SaraJaneQ Javascript How-To 4 November 9th, 2006 11:11 AM
Get ID from Labels that are dynamically generated bekim Javascript How-To 6 February 20th, 2006 04:52 AM
dynamically generated submenus elladi Dreamweaver (all versions) 9 December 24th, 2004 08:12 AM
dynamically generated pop up menus... elladi Dreamweaver (all versions) 7 August 1st, 2004 03:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.