Change text onclick

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
kevdog98
Super Advanced
Super Advanced
Posts: 36
Joined: Tue Sep 12, 2006 3:27 pm

Change text onclick

Post by kevdog98 »

Hi,

Is there a way to change the text of a menu item on click? For example that when a menu item is clicked it would change from "click" to "clicked".



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

Post by Ruth »

Hi,

Yes, there was a function created by Kevin for a user [me] who wanted that :)

The function is actually for onmouseover however I believe you can change it to be used with clickfunction. Here is the demo so you can see it in action.

http://support.milonic.com/demos/swap_text/index.htm

Follow the directions for copy and pasting the function in the menu_data file, but at the bottom where it gives you an aI string example make it this instead [ I don't know what your aI is so I'm just assuming it says Click

Code: Select all

aI("text=Click;clickfunction=mm_onText('Clicked');");
Note that once clicked it will always have the word Clicked there until you go to another page and the menu reloads. You'll also note that in the original there is an onfunction for the mouseover and an offfunction for the mouseout. Since yours is using clickfunction there is no offfunction.

I will contact Kevin and see if this is the best solution, but it works in IE FF NN and Opera.

Ruth
kevdog98
Super Advanced
Super Advanced
Posts: 36
Joined: Tue Sep 12, 2006 3:27 pm

Post by kevdog98 »

Ruth:

Thanks for the reply, but I can't get this to work with the collapse menu is there anything else I need to do?

Here is my code from the collapse_data.js file

Code: Select all

var mm_rollOffText; 
var mm_rollItem; 

function mm_onText(rollOnText) 
{ 
  mm_rollItem = _itemRef; 
  mm_rollOffText = _mi[mm_rollItem][1]; 
  _mi[mm_rollItem][1] = rollOnText; 
  BDMenu(_mi[mm_rollItem][0]); 
  itemOn(mm_rollItem); 
} 

function mm_offText() 
{ 
  _mi[mm_rollItem][1] = mm_rollOffText; 
  BDMenu(_mi[mm_rollItem][0]); 
  itemOff(mm_rollItem); 
} 




_scrollAmount=5      // Used for Netscape 4 scrolling 
_scrollDelay=10        // Used for Netscape 4 scrolling 

_menuCloseDelay=500  // The delay for menus to remain visible on mouse off 
_menuOpenDelay=150   // The delay for opening menus on mouse over 
_subOffsetTop=0;     // Sub menu offset Top position 
_subOffsetLeft=0;  // Sub menu offset Left position 

Goverfilter="Alpha(style=1,opacity=25,finishOpacity=100,startX=0,finishX=100,startY=100,finishY=0);Fade(duration=0.2);Shadow(color='#777777', Direction=135, Strength=5)" 
Goverfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color='#777777', Direction=135, Strength=5)" 
Goutfilter="randomdissolve(duration=0.3)" 
Goutfilter="" 
Goverfilter="" 

AllMargin=0 

treeOffset=0;  // Used to set the offset of sub menus 
singleMasterMenu=true // Informs the system to only have one menu open at a time 

with(tstyle1=new mm_style()){ 
offbgcolor = "#429491"; 
onbgcolor = "#357688"; 
offcolor="#357688"; 
oncolor="#FFFFFF";
pagecolor="#FFFFFF";
clickcolor="#FFFFFF";
clickbgcolor="#429491"; 
bordercolor="black"
borderstyle="solid";
borderwidth=0;
fontsize="11px";
fontfamily="Trebuchet MS";
itemwidth=114;
itemheight=30;
rawcss="padding:2px 0px 2px 4px"; 
keepalive=true;
} 



sub1Style=new copyOf(tstyle1) 
sub1Style.offcolor = "#429491"; 
sub1Style.offbgcolor="#8EA2BB" 
sub1Style.separatorcolor="#556E8C" 
sub1Style.clickcolor="#429491" 

sub2Style=new copyOf(tstyle1) 
sub2Style.offcolor = "#000000"; 
sub2Style.offbgcolor="#D6DDE6" 
sub2Style.separatorcolor="#8EA2BB" 


tstyle1.onbgcolor = "#357688"; 
tstyle1.offbgcolor = "#429491"; 

sub3Style=new copyOf(tstyle1)
sub3Style.padding=4;
sub3Style.fontsize="10px";

with(new menuname("main Tree Menu")){ 
top=190
left=0 
style = tstyle1; 
alwaysvisible = 1;
menuheight=30;
menuwidth=114;
margin=AllMargin 
aI("text=<b>Ministries</b>;url=ministries.asp?id=38;clickfunction=mm_onText('Min');");
aI("text=<b>Adults</b>;showmenu=Adults;type=tree;"); 
aI("text=<b>Young Adults</b>;url=ministries.asp?id=362;"); 
aI("text=<b>University Students</b>;url=ministries.asp?id=408;"); 
aI("text=<b>Jr.& Sr. High</b>;url=ministries.asp?id=410;"); 
aI("text=<b>Children & Families</b>;showmenu=CFM;type=tree;"); 
aI("text=<b>Music</b>;showmenu=Music;type=tree;");
} 

   with(new menuname("Adults")){ 
   style = sub3Style; 
   margin=AllMargin
   position="absolute"
   itemwidth=114;
   itemheight=30;
   aI("text=Adults;url=ministries.asp?id=364;"); 
   aI("text=What's Happening;url=ministries.asp?id=320;"); 
   aI("text=Class Schedule;url=ministries.asp?id=80;"); 
   aI("text=Opportunities to Serve;url=ministries.asp?id=344;"); 
   aI("text=Finding Community;url=ministries.asp?id=346;"); 
   aI("text=Caring Ministries;url=ministries.asp?id=404;"); 
   } 


   with(new menuname("CFM")){ 
   style = sub3Style;
   position="absolute"
   itemwidth=114;
   itemheight=30; 
   margin=AllMargin 
   aI("text=Children & Familes;url=ministries.asp?id=316;"); 
   aI("text=Calendar of Events & Activities;url=ministries.asp?id=374;"); 
   aI("text=Early Childhood;url=ministries.asp?id=366;"); 
   aI("text=Elementary;url=ministries.asp?id=368;"); 
   aI("text=Side-by-Side;url=ministries.asp?id=370;"); 
   aI("text=Resources for Teachers & Caregivers;url=ministries.asp?id=372;"); 
   aI("text=CFM Staff Directory;url=ministries.asp?id=372;"); 
   } 


   with(new menuname("Music")){ 
   style = sub3Style;
   position="absolute"
   itemwidth=114;
   itemheight=30; 
   margin=AllMargin 
   aI("text=Music;url=ministries.asp?id=376;"); 
   aI("text=Concert Schedule;url=ministries.asp?id=378;"); 
    

   } 

drawMenus()


Thanks.

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

Post by Ruth »

Hi,

I removed my other response. The problem is that you are clicking an item which is then loading a new page, there is no way that a function you have initiated on the 1st page in the menu file is going to be kept on the next page since on the next page the menu is reloaded and goes back to it's original state. What exactly are you trying to do, let them know where they are, or do you want something like a visited link so they can see all the places they've already been? If that is the case why not use the visitedcolor, that should remain no matter what page you go to.

Ruth
kevdog98
Super Advanced
Super Advanced
Posts: 36
Joined: Tue Sep 12, 2006 3:27 pm

Post by kevdog98 »

Basically, What I need to do is get a graphic to display every time a menu item is clicked. I have an arrow graphic that I can get to work on the clicksubimage but not on every item using the clickimage. I was working with Kevin on this but he has not replied to my post. So I thought maybe if I could use a text arrow onclick but that does not work either. SoI guess the ideal solution would be to get my arrow image to display centered on the right everytime an menu item is clicked. Is there anyway tod do this?


Thanks so much for your help.

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

Post by Ruth »

Hi,

I believe Kevin's response was going to be about making a taller gif image that was transparent top and bottom with the arrow in the middle. It's not exact because as font size changes so do the item height.

Ruth
Post Reply