Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,399 Programmers. There are 1,463 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Auto-recognise date on a website

 
Reply to this topicStart new topic

Auto-recognise date on a website, Use the date to build links - can this be done in HTML / Javascript?

saturday79
post 26 Apr, 2008 - 06:49 AM
Post #1


New D.I.C Head

*
Joined: 26 Apr, 2008
Posts: 2



What I'm looking to do is set up a blog with a new HTML page for each day.

I'd like to be able to upload multiple blogs in one go, i.e. load all pages for the coming week. When visitors access the site, they should see on index.html the entry for that particular day (i.e. the site will recognise that it is Tuesday and show Tuesday's entry, even though I've uploaded posts until Friday).

There should then be links to 'previous day' and (on everything other than today's post), 'next day', which should again be automatically worked out.

Is there any way of doing this in HTML / Javascript or something relatively simple which won't require a server-side d/b?

All help greatfully appreciated, thanks!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


PsychoCoder
post 26 Apr, 2008 - 06:54 AM
Post #2


ToCode || !ToCode

Group Icon
Joined: 26 Jul, 2007
Posts: 5,858

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

saturday79
post 27 Apr, 2008 - 09:17 AM
Post #3


New D.I.C Head

*
Joined: 26 Apr, 2008
Posts: 2

Ok..

I've tried putting some code together, but it's not working. I know I'm doing something daft somewhere, pointers appreciated!

In the <head> I've put the following:
CODE

<script TYPE="text/javascript">
<!--
var pDate= "20080401";

function checkDate(pDate){
var now=new Date();
var yy= now.getYear();
Tyy = yy.toString();
var mm= now.getMonth();
Tmm = mm.toString();
var dd= now.getDate();
Tdd = dd.toString();
var todayDate= Tyy+Tmm+Tdd;
}
//-->
</script>


I then have the following <body> tag:
CODE

<body background="bgsq.jpg" onload="checkDate()">


Further down the page, I have:
CODE

<td>
<script TYPE="text/javascript">
<!--
if (todayDate > pDate){
document.write("<b><a href="link.html">next day ></a></b>");
}
//-->
</script>
</font></p>
</td>


Not sure why this doesn't show, bearing in mind I think todayDate should be 20080427 and that I've set pDate to 20080401.

Thanks
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

ahmad_511
post 27 Apr, 2008 - 11:45 AM
Post #4


D.I.C Regular

Group Icon
Joined: 28 Apr, 2007
Posts: 302

hello
the variables scope is important thing.
todayDate is a local variable within your function,so define it out of the function so you can read it anywhere else in the document
jscript

var pDate= "20080401";
var todayDate;

User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 06:23AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month