Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:51
Can you add the current date into a menu?
Poster: pbyrne
Dated: Friday October 20 2006 - 6:57:14 BST
I'm wondering if there is an easy way to incorporate a current date into the menu.
For reference, my draft menu is at: http://www.dracoblu.com/testindex.html
I wish to place a current date in the horizontal menu aligned to the far right.
If anyone has suggestions it would be greatly appreciated.
Thanks, Pat
Poster: Ruth
Dated: Friday October 20 2006 - 9:32:08 BST
Hi,
You can use the menuclock.js module and set up a current date and time. I will check to see if it's possible to get it to only set the date and post back when I find out. You can find a demo of it under the demos, it will be the 2nd one under the bolt-on module demos at the bottom. Make sure you download the newest menuclock.js file. There is a link for it at the bottom of the clock demo page.
http://support.milonic.com/demos/
One thing to note, since you are putting the menu into a div, there's really no way to get the date to be aligned to the right unless you change the layout to have two separate menus in their own divs or put a two column table into that div and put the clock data file into the right had column. For example:
Code:
<DIV class=topnav id=nav><table width="100%"; cellpadding=0 cellspacing=0 border=0>
<tr>
<td><SCRIPT language=javascript src="embed_main.js"
type=text/javascript></SCRIPT></td>
<td><SCRIPT language=javascript src="clock_main.js"
type=text/javascript></SCRIPT></td>
</tr>
</table>
</DIV>
<tr>
<td><SCRIPT language=javascript src="embed_main.js"
type=text/javascript></SCRIPT></td>
<td><SCRIPT language=javascript src="clock_main.js"
type=text/javascript></SCRIPT></td>
</tr>
</table>
</DIV>
Your clock_main.js would be
Code:
with(milonic=new menuname("clock")){
style=style1;
alwaysvisible=1;
orientation="horizontal";
position="relative";
aI("valign=top;text="+getMilonicDate()+";align=right;type=clock;offbgcolor=#000000;onbgcolor=#000000;offcolor=#ffffff;oncolor=#ffffff;");
}
drawMenus();
style=style1;
alwaysvisible=1;
orientation="horizontal";
position="relative";
aI("valign=top;text="+getMilonicDate()+";align=right;type=clock;offbgcolor=#000000;onbgcolor=#000000;offcolor=#ffffff;oncolor=#ffffff;");
}
drawMenus();
And you would need to add the menuclock.js module call like this before you menu_data file
Code:
<SCRIPT language=Javascript src="menuclock.js" type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="bonesingermenu_data.js"
type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="bonesingermenu_data.js"
type=text/javascript></SCRIPT>
Hope this helps.
Ruth
Poster: pbyrne
Dated: Friday October 20 2006 - 16:10:05 BST
Thanks Ruth. I will investigate this, but if you find a date only module, that would be ideal.
Enjoy a great weekend.
Poster: Ruth
Dated: Friday October 20 2006 - 17:39:59 BST
Hi,
Normally I would not do modifications since in most cases I wouldn't know how. But, since I figured this one out and Andy said it was OK you can get date only like this.
Download the menuclock.js file and open it in a text editor. Find this line
Code:
return dayNames[_dayNum]+" "+_day+getNumberSuffix(_day)+" " + monthNames[_month] + " " + _year + "<BR><b>" + _time+"</b>"
And change it to this
Code:
return dayNames[_dayNum]+" "+_day+getNumberSuffix(_day)+" " + monthNames[_month] + " " + _year + " "
And now you have only the date.
Ruth
Poster: pbyrne
Dated: Friday October 20 2006 - 19:42:29 BST
Thanks Ruth. I have incorporate the code into the menu at: http://www.dracoblu.com/testindex.html
A couple of problems I have noticed....The date appears as a hyperlink with an error of: javascript:void(0) in both FF and IE. I also notice that in IE the horizontal menu bar is double with width than it is in FF. I am not sure why...if you have any suggestions that would be great.
Thanks, Pat.
Poster: Ruth
Dated: Friday October 20 2006 - 22:19:54 BST
Hi,
It's something built in about the form. It's as if the form automatically puts a br after the form close tag, I think it's some kind of margin because setting margin in the aI fixes it.
Code:
aI("text=`<form><input><input> <input></form>`;type=form;");
That seems to eliminate that extra space.
Ruth
Poster: pbyrne
Dated: Friday October 20 2006 - 22:39:28 BST
Interesting.... I can't seem to make that extra horizontal disappear in IE by putting in I am running IE6
Any thoughts on that other JS error related to the date?
Poster: Ruth
Dated: Saturday October 21 2006 - 0:15:33 BST
Interesting, the code buttons don't seem to be working right.
Ok I'm changing your < brackets to [ so I can post the code. Don't forget to change them back to <and>
Code:
aI("text=`[form style='margin:0px;' method=get action=http://search.atomz.com/search/]
I'm not sure what's going on I'll have to post to Andy.
Ruth
Poster: Andy
Dated: Saturday October 21 2006 - 8:10:54 BST
Hi,
Here's how to get rid of the extra space:
Code:
aI("text=`<form><input> <input> <input></form>`;type=form;");
Here's a fix for the error, you had 2 hashes for the oncolor:
Code:
aI("valign=top;text="+getMilonicDate()+";align=right;type=clock;offbgcolor=#003366;onbgcolor=#003366;offcolor=#ffffff;oncolor=#ffffff;");
Not much we can do about the javascript:viod problem because the link is being echoed to the status bar to indicate where the link supposed to be linking to, it's a security thing.
-- Andy
Poster: pbyrne
Dated: Thursday October 26 2006 - 16:29:22 BST
Thanks Andy.... I did not see your reply right away, so it has been a few days.
I removed the extra hash mark in the clock_main.js, and inserted the no break space a few different ways in the embed_main.js file, but I cannot seem to remove the extra horizontal space in IE. Here is the current code I have associated with http://www.dracoblu.com/testindex.html
aI("text=`<form method=get action=http://search.atomz.com/search/> <input type=submit value=Search style='color: #010425; font-family: arial; font-size: 11px' /> <input type=hidden name=sp-a id=sp-a value=sp10015b5a /> <input type=text size=20 name=sp-q id=sp-q style='color: #010425; background-color: #eeeeee; font-family: arial; font-size: 11px' /></form>`;type=form;");
}
Any help would be appreciated. Thanks, Pat.
Poster: John
Dated: Thursday October 26 2006 - 20:37:42 BST
IE7 really messes things up (including the rounded corner box!).
Looking at it now but now sure if I can help, as I no longer have IE6.
Poster: pbyrne
Dated: Thursday October 26 2006 - 21:06:52 BST
Thanks John... I have not played with IE7, so if you have any suggestions that would be great. It is still in beta, right?...Maybe that will make a difference.
This is a bit off topic, I will be trying to make this a CSS compliant website. Do you have a CSS alternative to a table for this part of the code calling the menu and clock?
<div class="topnav" id="nav"><table width="100%"; cellpadding=0 cellspacing=0 border=0>
<tr>
<td><SCRIPT language=javascript src="embed_main.js"
type=text/javascript></SCRIPT></td>
<td><SCRIPT language=javascript src="clock_main.js"
type=text/javascript></SCRIPT></td>
</tr>
</table>
</div>
Thanks again.
Poster: John
Dated: Thursday October 26 2006 - 21:44:36 BST
No, both IE7 and FF2 are now final releases - well, depending on just how 'final' a first release can be...
Can't help you with the script to CSS thing. Sorry.
Poster: Ruth
Dated: Sunday October 29 2006 - 0:18:14 BST
Hi,
I don't know what you mean by something different than the table. If you correct the errors the page will validate.
I don't do xhtml but I did get it to validate after fiddling until I could figure out what the errors were. that shorttag=yes I finally found was that you had to put quotes around things like class=topnav, cellpadding=0, type=text/javascript. I believe you can remove the language=javascript from the calls for the two files that were causing problems
Code:
<script src="embed_main.js" type='text/javascript'></script>
It seems to still work, but I don't have all browsers to check it.
Ruth
Poster: pbyrne
Dated: Monday October 30 2006 - 20:15:01 GMT
Thanks for the reply, Ruth.
I have played with removal of the language=javascript command, but that does not change the display of the menu search in a two line block in IE7. FF displays properly.
The current draft can be viewed at:
http://www.dracoblu.com/testindex1.html
Poster: Ruth
Dated: Monday October 30 2006 - 21:55:37 GMT
Hi,
My response was to the validation.
You did not include the style and margin: 0px in the form which was how I got rid of the extra space.
EDIT: Link Removed
Ruth
Poster: pbyrne
Dated: Monday October 30 2006 - 22:19:49 GMT
Thanks Ruth. I got the files, and inserted the style for the form. It works!
I have not eliminated the idea of a date in the menu. I am trying to avoid a table to call the clock_main.js or another similar JS file that I have on hand called date.js ...The CSS is not co-operating and placing the info behind the menu.
Thanks again for you help. I really appreciate it.
Poster: Ruth
Dated: Monday October 30 2006 - 22:27:10 GMT
Hi,
Well, I really don't do any real css since there is no place that gives you explanations that are easy to understand and visuals to see what's happening when you change things so you can see how they work, absolute, relative, fixed static and so on and so on and oh if borders meet then this happens and that happens. Sorry that the table is the only way I know to do it that I can position correctly. When they create something that makes sense as to divs and positioning them I'll do more css
However, for those who know css, divs and positioning, I'd think one should be able to place two divs side by side one for the menu one for the date right where you have the one div now into which I put the 'oh so easy to configure and put where you want it so it will stay there' table.
Ruth
Poster: pbyrne
Dated: Monday October 30 2006 - 22:31:41 GMT
Thanks Ruth... I know what you mean.
I will continue to work on it.
Re: Can you add the current date into a menu?
Poster: wuscheck
Dated: Wednesday January 13 2010 - 8:31:49 GMT
Hi ruth,
I have a question concerning menuclock.js... What is the right place for the
Code:
<SCRIPT language=Javascript src="menuclock.js" type=text/javascript></SCRIPT>
when I'm using the php-version of milonic because there is no
Code:
<SCRIPT language=Javascript src="menu_data.js" type=text/javascript></SCRIPT>
Is this the right way to call the clock after placing the scipt-code in the right way?
Code:
$mmMenu->addItemFromText("text=`+getMilonicDate()+`;align=center;type=clock;");
Thanks in advance...
wuscheck
Re: Can you add the current date into a menu?
Poster: wuscheck
Dated: Wednesday January 13 2010 - 9:32:00 GMT
I got it... learning by doing
Re: Can you add the current date into a menu?
Poster: wpatters1229
Dated: Saturday May 1 2010 - 21:57:53 BST
I am not that good at scripts and am wondering if you can change the order of the date?
Right now is says Sat 1st May 2010....would like it to say just May 1, 2010
Is there a way to tweak the code to do that?
Thanks
Re: Can you add the current date into a menu?
Poster: wpatters1229
Dated: Monday May 3 2010 - 15:54:52 BST
Thanks for the help...I actually played with the code and figured out how to do it along with using the piece that adds the "st" or the "rd" etc. depending on the numeric day. So not it shows "May 1st 2010" or as for today "May 3rd 2010"
Coding always frustrates me since I always forget the syntax and if you miss one little semi-colon or comma it all goes away...
Was never that good with written languages either....memory thing or just not that kind of a brain. I am much better at solving problems and engineering.
Re: Can you add the current date into a menu?
Poster: wuscheck
Dated: Monday May 3 2010 - 14:29:38 BST
Change the menuclock.js like this... it's untested:
Code:
+ monthNames[_month]+_day+","+ _year
The array for the monthNames:
Code:
monthNames=new Array("January", "February", "March",.....