dynamically change menu style

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
BigWebGuy
Advanced
Advanced
Posts: 15
Joined: Wed Apr 27, 2005 5:05 pm

what am i doing wrong? substyle not being applied

Post by BigWebGuy »

well, i've almost got it working, but the substyle is not being applied. it's applying the new mainstyle but it's also using the mainstyle for the submenus instead of the substyle.

https://www.eval2.asmr.com/milonictest/stulogon2.htm

i'm stumped at this point. Andy? Any suggestions?
Ram_Tough
Beginner
Beginner
Posts: 2
Joined: Tue Jun 28, 2005 11:51 pm

dynamically change menu style

Post by Ram_Tough »

Hello!

I have been looking the thread "dynamically change menu style" and was able to successfully use the javascript method that Andy suggested. (the "changeStyle" method)

However, I would like to know if it's possible to write that method so that it uses a specific menu (I have 2 separate menus) to set the style for....

Thanks!

Jason
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

You need to provide more information before we can answer this. Could you post a page so we can see it and the two menus? I'd think you could just apply it to whichever menu you want the changeStyle to apply. So, do you have two separate menu files, or are you doing two menus in one file? Where are you putting the code, on the page, in the file?

For others more code literate they might be able to figure out what you want and how to do it, but for myself, I need to see the page or the coding i.e. menu_data.js file codes, html code. And, that still might not let me figure it out ;)

Ruth
Ram_Tough
Beginner
Beginner
Posts: 2
Joined: Tue Jun 28, 2005 11:51 pm

dynamically change menu style

Post by Ram_Tough »

:oops:

I guess I should realize that nobody can read my mind! LOL...Anyways, to explain better:

I have a page that has a horizontal menu at the top of the page. It's in a file called main_menu_data.js This menu is consistent across all of my pages. I also have a vertical menu on the side that contains common links to all of my pages. (it's in a separate file called links_data.js)

What I would like to do is have the links_data.js menu have a different style (basically a different background color) applied to it depending on what page it's on. So, in one page, I would have a javascript method that changes the style so that the background color is blue, and in another page, I would use the same javascript method to change the style to a red background color.

Here's the code for main_menu_data.js:

Code: Select all


padding=10;
subimagepadding=2;
menubgcolor="#EDE2F0";
onbgcolor="#ffffff";
offbgcolor="#EDE2F0";
oncolor="#000000";
offcolor="#000000";
itemwidth=200;


//sets the border style (and color) for the menu
borderstyle="solid";
borderwidth=1;
bordercolor="#BABABA";


//sets the separator style (and color)
separatorcolor="#ffffff";
separatorsize="1";

//sets the subimage indicator
subimage="images/arrow.gif";
}




//*****************************Main Menu*****************************

with(milonic=new menuname("Main Menu")){
alwaysvisible=1;
openstyle="tab";
orientation="horizontal";
style=mainMenuStyle;
position="absolute";
aI("bgimage=images/buttonHome.jpg;overbgimage=images/buttonHomeOver.jpg;align=center;text=Home;");
aI("bgimage=images/ButtonCorpDept.jpg;overbgimage=images/ButtonCorpDeptOver.jpg;align=center;text=Corporate Department;showmenu=Corp Main 

Menu;");
aI("bgimage=images/ButtonStratCorp.jpg;overbgimage=images/ButtonStratCorpOver.jpg;align=center;text=Strategic Corporate 

Services;showmenu=SCS Main Menu;");
aI(";");
}




//*****************************CORP Main Menu***************************************
with(milonic=new menuname("Corp Main Menu")){
style=corpMenuStyle;


orientation="vertical";

aI("text=Corporate departments;showmenu=corp;");
aI("text=Connections magazine;url=InsertURLHere.htm;");
}


//***************************SCS Main Menu********************************
with(milonic=new menuname("SCS Main Menu")){
style=SCSMenuStyle;

orientation="vertical";
aI("text=Human Resources;url=InsertURLHere.htm;");
aI("text=Financial Services;url=InsertURLHere.htm;");
aI("text=Business Planning &<BR>Performance Measurement;url=InsertURLHere.htm;");
aI("text=Information Systems;url=InsertURLHere.htm;");
aI("text=Records Management &<BR>FOIP Co-ordination;url=InsertURLHere.htm;");
}


//***************************Finish********************************
drawMenus();
Here is the code for links_data.js:

Code: Select all


// sets the padding for the menu item 
padding=5;

//sets the border style (and color) for the menu
borderstyle="solid";
borderwidth=1;
bordercolor="#949494";

menubgcolor="#ECECEC";
onbgcolor="#ffffff";
offbgcolor="#ECECEC";
oncolor="#000000";
offcolor="#000000";
itemwidth=200;

//sets the separator style (and color)
separatorcolor="#ffffff";
separatorsize="1";
//separatorwidth="50%";


//sets the subimage indicator
subimage="images/arrow.gif";
}

//***************Links Menu***************

with(milonic=new menuname("Links Menu")){
style=linksMenuStyle;
top=10;
left=0;
alwaysvisible=1;
orientation="vertical";
position="relative";
itemwidth="198";

//
//  COMMUNICATIONS - LINKS TO ALL PAGES - Enter an aI for each link as follows:
//
//	aI(text=place your link text here";url=http://this is your url");
//
//----------------------------------------------------------------------

aI("text=Questions and Feedback;url=/insertpageurlhere.htm;");
aI("text=Other Links;url=/insertpageurlhere.htm;");
aI("text=Sub Menu;showmenu=Search;);
//----------------------------------------------------------------------
}

//***************SubLinks***************

with(milonic=new menuname("Search"))
{
style=SubLinksMenuStyle;
aI("text=Community Development;url=http://srms/AD/adFindUser.aspx;");
aI("text=Government of Alberta;url=http://www.gov.ab.ca/home/index.cfm?page=5;");
aI("text=Calgary White Pages;url=http://internal4.gov.ab.ca/phonebooks/calgary-white/;");
aI("text=Calgary Yellow Pages;url=http://internal4.gov.ab.ca/phonebooks/calgary-yellow/;");
aI("text=Edmonton White and Yellow Pages;url=http://internal.gov.ab.ca/phonebooks/edmonton/index.htm;");
}


drawMenus();
I use

Code: Select all

<script src="main_menu_data.js"></script>
within a td of a table, and

Code: Select all

<script src="links_data.js"></script>
within a separate td in that table to display the menus. (I can post the html for you, but I think that part is pretty self-explainatory)

Anyways, if I use the changeStyle method that Andy described in his post, it changes the style on both menus....but I only wanted it to change the style on the menus declared by links_data.js....

Thanks in advance for any ideas you can give me!

Jason[/code]
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi Jason,
Ram_Tough wrote:I guess I should realize that nobody can read my mind!
Actually, probably the guys who know the functions would know what you wanted :)

Unfortunately, I am function illiterate :? so, I 'gotta see it' to figure out things. So, where exactly is the function? If it's on the page, I guess you'll have to post the html, or if it's in some other file, I'll need to see that. Sorry, it's the only way I can experiment and figure a solution :oops:

Ruth
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi Jason,

I'm back again. I have to tell you I'm not going to be able to figure this out. I can't even figure out what is happening with the files you posted. I can't find any styles listed in them, though the menus call for mainMenuStyle and linksMenuStyle but though I see style properties listed at the top of the files there are no style names for those.

I can make two suggestions:

1. put the function into the menu data file where you want it to be applied.

2. you could use a class to assign bgcolors to a menu, however that would mean actually putting the class in the head of each page where you want it to be called. If you do that, you'd then put onclass="yourClassName"; and offclass="yourClassName"; into the style for that menu.

The reason it would have to go into the head of each page where you wanted a change is that it has to be a 'different' color on the various pages.

I actually have done that on my site, but it's a small site and since I have nothing much else to do, I didn't mind coding all the pages :) So, my menu changes color on every page to match the page colors.

Ruth
BigWebGuy
Advanced
Advanced
Posts: 15
Joined: Wed Apr 27, 2005 5:05 pm

Post by BigWebGuy »

what about me? (stomps foot on the ground). this was my thread first, can anyone help me out?
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

:;putting hands on hips, tapping foot:: Now, stop that foot stomping, or let's have some music and make it a dance round! :)

Sorry for it taking so long. I'm sure Andy or Kevin will get back to you. Kevin is out of town for I don't know how long and I think Andy got dragged into a black hole by Alice's wabbit!

I know it's not funny, and wish I could help, but I'm sure you're aware that this is beyond me :? I'll try posting a nudge to Andy.

Ruth
BigWebGuy
Advanced
Advanced
Posts: 15
Joined: Wed Apr 27, 2005 5:05 pm

Post by BigWebGuy »

ruth, any progress on passing this on to someone? I'm a registered user and i've submitted a question to the registered users support but havent heard back in over a month, so this is my only shot at getting this figured out. thanks.
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,

I've posted again. I'm not sure but I think the support requests are for professional and above license. If you have that, you might send in another request. I remember the site was down at one point and Andy had to 'reinitialize' or whatever you call it and get it up. Perhaps something got lost. Also, as you might have noted, everyone has pretty much been gone for awhile. I know Kevin was out of town and I'm not sure if he's back even yet. John was also out, so we've been kind of short on board help.

Hopefully, they will all be back soon!

Just out of curiosity, since I am thoroughly lost :oops: what was it that wasn't working in the link Andy posted for you?

Ruth
BigWebGuy
Advanced
Advanced
Posts: 15
Joined: Wed Apr 27, 2005 5:05 pm

Post by BigWebGuy »

yeah, we have the professional license. i'll try posting again.

the problem i'm having is that when i change the menustyle, it applies the main menustyle to all menus instead of applying the main menu style and sub menu styles.

it's the first post on the second page of this thread.

thanks for your help.
Post Reply