Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic dhtml menus

Status
Not open for further replies.

btween

Programmer
Aug 7, 2003
338
US
I am trying to load a dhtml menu with some recordset values, but I don't know how to do this because response.write does not seem to work within a function

this is the static menu below:

Code:
function mmLoadMenus() {
  if (window.mm_menu_1024161616_0) return;
      window.mm_menu_1024161616_0 = new Menu("root",119,16,"Arial, Helvetica, sans-serif",12,"#999999","#CCCCCC","#FFFFFF","#FFFFFF","left","middle",2,0,200,-5,7,true,true,true,0,true,true);
  mm_menu_1024161616_0.addMenuItem("brooches","location='jewlery.asp?cat=brooches'");
  mm_menu_1024161616_0.addMenuItem("necklaces","location='jewlery.asp?cat=necklaces'");
  mm_menu_1024161616_0.addMenuItem("earrings","location='jewlery.asp?cat=earrings'");
  mm_menu_1024161616_0.addMenuItem("bracelets","location='jewlery.asp?cat=bracelets'");
  mm_menu_1024161616_0.addMenuItem("rings","location='jewlery.asp?cat=rings'");
  mm_menu_1024161616_0.addMenuItem("hair accessories","location='jewlery.asp?cat=hair_accessories'");

What i would like to do is replace "brooches" with <%=rsJewlery("category")%> and jewlery.asp?cat=brooches with
"jewlery.asp?cat=" <%=rsJewlery("category")%>

any help is appeciated.
 
Instead of trying to write the category within the function, you could just pass that information to the function in the function call. I assume you have the function call in the body tag onload event. Change onload="mmLoanMenus();" to onload="mmLoanMenus('<%= rsJewlry("category") %>');". Then change your function to: function mmLoadMenus(cat) {

Then the location part would be location='jewlry.asp?cat=" + cat + "'");

By the way, jewlry is spelt jewelry.
 
Hi

What you need to do is as follows:

Code:
function mmLoadMenus() {
  if (window.mm_menu_1024161616_0) return;
      window.mm_menu_1024161616_0 = new Menu("root",119,16,"Arial, Helvetica, sans-serif",12,"#999999","#CCCCCC","#FFFFFF","#FFFFFF","left","middle",2,0,200,-5,7,true,true,true,0,true,true);

[COLOR=red yellow]<% While NOT rsJewelery.EOF  %> [/color]
mm_menu_1024161616_0.addMenuItem("<%= rsJewelry("category") %>","location='jewlery.asp?cat=<%= rsJewelry("category") %>'");
[COLOR=red yellow]rsJewelery.movenext
wend
%>[/color]
This will loop out all of the categories and corresponding links in to the DHTML menu array.

Let me know how you get on.

Thanks


Glen
Conception | Execution
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top