Auto-Date

Lotus123

New Member
I have a couple of situations where I am tired of updating a date and would like to do it automatically. I am not an expert programmer, but I am pretty good at inserting spaghetti code and making already existing code work in my website; however, I haven't been able to find what I need for this:

Code:
       <select name="menuopts" onChange="goDestination(document.mymenu.menuopts.options[document.mymenu.menuopts.options.selectedIndex].value)">
       <option>Quick Links...</option>
       <option value="guestbook.html">Community</option>
       <option value="credits.html">Credits</option>
       <option value="pages/Sep2008.html">Current Diary Page</option>
       <option value="main.html">Main Page</option>
       </select>

Is it possible to dynamicly generate the spot that shows Sep2008 to show the current MmmYYYY?

Here is my second question:
I have a line that looks like this on the same page:

Code:
   <font face="Comic Sans MS" size="1">Last Updated September 14th, 2008</i></font></p>

I would like the date here to be whatever date a specific file was modified. This file is located at "pages/site-index.html" in relation to the page that has this code.

Any help is greatly appreciated. Thanks a bundle!
 

wetgravy

New Member
Sadly most of the scripting i know for that is meant for sites with admin support or php/database updating capabilities ... if you want a site that has auto capabilities ... look to a CMS.
 

jnjc

New Member
To make the link dynamic is pretty easy, this should do what you need:

Code:
<script type="text/javascript">
function getMonthFile() {
var months = new Array(12);
today = new Date();
months[0] = "Jan";
months[1] = "Feb";
months[2] = "Mar";
months[3] = "Apr";
months[4] = "May";
months[5] = "Jun";
months[6] = "Jul";
months[7] = "Aug";
months[8] = "Sep";
months[9] = "Oct";
months[10] = "Nov";
months[11] = "Dec";

return "pages/" + months[today.getMonth()] + today.getFullYear() + ".html";

}

</script>



<body>
<a  onmouseover="this.href=getMonthFile();" >test</a>
</body>

To display a date and time based on the modification date/time of a file is not so straight forward. JS code is executed client side and I am not sure if you can access the file mod information client side. You may need to come up with a server side script to do this...

HTH,
JC
 

joe

New Member
I think with what you're wanting you'll need to go to a server side language. I don't think jnjc's suggestion will help because you're wanting something to be there when the page loads and javascript really can't do that to my knowledge.
 

Phidev

New Member
use document.lastModified parse it, and write the date the way you want it, it is not too complicated
 

Geodun1

New Member
I think with what you're wanting you'll need to go to a server side language. I don't think jnjc's suggestion will help because you're wanting something to be there when the page loads and javascript really can't do that to my knowledge.

JNJC's suggestion SHOULD work fine for this set up. It builds the link based on the month and year, which is what our friend is looking for.
 
Top