 |
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
|
|
|
|

November 18th, 2003, 07:41 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
dynamically generated url's
greetings
I wonder if you can help me again :). I would like to create a navigation bar using the show pop up menu behaviour. Is it possible to load the links in here dynamically?
regards
Steve
|
|

November 18th, 2003, 04:31 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, yeah, but it all depends on your "dynamic technology".
Take for example an ASP page. Then this would work:
<%
Dim anURL
anURL = Code To Get URL from Database Here
%>
<script language="JavaScript" type="text/javascript">
// Menu code here.
var MyLocalJavaScriptVar = '<%=anURL%>'
</script>
This code will write out the value of anURL to the client side JavaScript. This means you can added dynamic, server side generated URLs to client side JavaScript.
Does this help??
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 19th, 2003, 11:58 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:):):)
Yes it helps to know it can be done, but looks to be way beyond my ability :(
Basically, having worked through your book, (and several others) I set myself a project of putting together a small database driven site, and I wanted to use a show pop-up menu type menu to navigate to a set of filtered product pages all based on the same page.
I have trawled through the macromedia forums trying to find some info on how to do this but drawn a blank, which is why I posted here.
Perhaps I will try something simpler, thanks for the reply
regards
steve
|
|

November 19th, 2003, 12:46 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Well, IMO, it shouldn't be too difficult. If you want, I can try to help you with it (I don't have too much time at the moment, but I'll do my best anyway).
The hardest thing is understanding the code that Dreamweaver has created for the pop-up menu. Once you understand that, it's pretty easy to write some code that connects to a database (Access, SQL Server, whatever), writes out the necessary JavaScript that then gets send to the browser. This database stuff can be pretty much the same as the database code in TheSoccerSite project in the book.
Here's what I would do:
1. Create a very simple pop up menu that reflects the ideas you have on the final navigation system. Create a few levels in the menu, and make sure you add at least two items on each level (to see how multiple items work).
2. Study the DW code a bit. You don't have to understand exactly what it does; on the contrary: all you need to know is where DW has put the page names and other info for each of your menu items. Try to discover how the nested items work, where URLs go, etc.
3. Create some ASP code that writes out the JavaScript you created in step 1 and 2. Start by doing some hard coded stuff, so you can see how it works.
4. Hook up your ASP code to some database code, so each menu item gets written dynamically.
It's like the squirrel from the White Stripes album: "Take all your problems and rip them apart". By breaking this coding problem into a series of smaller problems, things get a lot easier. I think that with the help of a good book (you just confirmed you had a good one ;) ), and some support from me and this forum, I don't believe things are beyond your ability. All you need is the will to do it.....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 20th, 2003, 10:55 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:)
OK I will give it a go!
I have already tried inserting the ASP code - something like product_pages.asp?productID=1<%=rs_productNames.fi elds.item("productID").value%> into the pop up menu javascript where it references the target page - but that didnt work.
Do I have to write seperate variables for each target url as in the code in your first reply?
regards
steve
|
|

November 20th, 2003, 11:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Steve,
Does the following code help?? You should be able to copy the entire code block, paste it in a new ASP document and run it in your browser to get it to work.
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript">
<!--
function mmLoadMenus() {
if (window.mm_menu_1120161301_0) return;
window.mm_menu_1120161301_0 = new Menu("root",63,18,"",12,
"#000000","#FFFFFF","#CCCCCC","#000084",
"left","middle",3,0,1000,-5,7,true,true,true,0,true,true);
<%
Dim LoopCounter
For LoopCounter = 0 To 9
Response.Write("mm_menu_1120161301_0.addMenuItem(""Item " & _
LoopCounter & """,""location='Item.asp?ID=" & LoopCounter & "'"");")
Next
%>
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()
//-->
</script>
<script language="JavaScript" src="mm_menu.js"></script>
</head>
<body>
<script language="JavaScript1.2">mmLoadMenus();</script>
<a href="test.asp" name="link1" id="link1"
onmouseover="MM_showMenu(window.mm_menu_1120161301_0,100,16,null,'link1')"
onmouseout="MM_startTimeout();">My Products</a>
</body>
</html>
This code uses a simple Pop up Menu. At the location where the individual items are added to the menu, I added some ASP code.
This code loops from 0 to 9 to write out 10 menu items. Each menu item gets the name of Item + The Loopcounter, like Item 1, Item 2 abd so on. Each menu item links to Item.asp and as an ID param it gets the LoopCounter value. So, the previous two menu items would link to Item.asp?ID=1 and Item.asp?ID=2 respectively.
It should be relatively easy to replace the LoopCount with a Recordset, so you can write out links to real products. You could even create sub menus with the name of the category a product belongs to, although you may be better of keeping things simple in the beginning.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 20th, 2003, 01:21 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:)
Thankyou - it will take me some time to understand all of that, I will try things out tomorrow
regards
steve
|
|

November 25th, 2003, 04:09 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Steve,
Any luck so far? Getting anywhere? I don't know whether you posted something over the weekend, so I was getting curious wether you're succeeding or not.....
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

November 26th, 2003, 06:17 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
greetings :)
Just after my post I had a few problems - my computer at my office finally died, so now have shiny new XP Pro machine which is totally different from win98. I hope to start again on the project in the next few days.
regards
steve
|
|

November 26th, 2003, 12:46 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
greetings :)
Had some time today to start thinking about this.
I thought the best way to start was to produce a set of dynamic links as a list on a page (to compare the code with your loopcounter and menu code) and make those work with an output page - this seems to work fine
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim rs_productNames
Dim rs_productNames_numRows
Set rs_productNames = Server.CreateObject("ADODB.Recordset")
rs_productNames.ActiveConnection = MM_connAlstoeTest_STRING
rs_productNames.Source = "SELECT * FROM tblProducts"
rs_productNames.CursorType = 0
rs_productNames.CursorLocation = 2
rs_productNames.LockType = 1
rs_productNames.Open()
rs_productNames_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rs_productNames_numRows = rs_productNames_numRows + Repeat1__numRows
%>
<html>
<head>
<title>product home</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_productNames.EOF))
%>
<a href="product_page.asp?productID=<%=(rs_productNam es.Fields.Item("productID").Value)%>"><%=(rs_produ ctNames.Fields.Item("productName").Value)%></a><br />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_productNames.MoveNext()
Wend
%>
</html>
<%
rs_productNames.Close()
Set rs_productNames = Nothing
%>
Initial thoughts -
The initial recordset code appears above the <head> tags
The function mmLoadMenus() and the loopcounter code are within the <head> tags
Have tried directly replacing the loopcounter variable with the recordset variable - not correct :(
Do I use the loopcounter/addItem or the repeat region code?
Will try some more tomorrow :)
regards
steve
|
|
 |