JS issue

This is a discussion on "JS issue" within the JavaScript Forum section. This forum, and the thread "JS issue are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 23rd, 2007, 15:39
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
JS issue

Built this text generator depending on the month, but it does not work, can someone please check to see where I have gone wrong please:

HTML: Select all
<html >

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>JS</title>
</head>


<body>
 
<script>

var Digital=new Date()
var month=Digital.getMonth()

if (the_month()==0&&month<=2) 
{document.write("Our school talk tour on extreme Freeride is now taking bookings for the Summer term.");}

if (the_month()==3&&month<=5) 
{document.write('Our school talk tour on extreme Freeride is now taking bookings for the Autumn term');}
if (the_month()==6&&month<=11) 
{document.write('Our school talk tour on extreme Freeride does not take booking for the Spirng term');}

</script>

</body>

</html>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jul 25th, 2007, 02:54
Junior Member
Join Date: Jul 2007
Location: Sydney
Age: 27
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Re: JS issue

Try this:

Code: Select all
<script>

var Digital=new Date()
var month=Digital.getMonth()

if (month<=1 && month<=3) 
{document.write('No Booking between months 1 and 3');}
else if (month<=4 && month<=7) 
{document.write('No Booking between months 4 and 7');}
else if (month<=8 && month<=12) 
{document.write('No Booking between months 5 and 12');}

</script>
I've screwed up your dates there, so just change the numbers and message as you see fit.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jul 25th, 2007, 09:57
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: JS issue

It works up to August then drops out and I thought the months were one behind what they were on a calendar,

0=January
1=February
2=March
3=April
4=May
5=June
6=July
7=August
8=September
9=October
10=November
11=December
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jul 25th, 2007, 16:02
Junior Member
Join Date: Jul 2007
Location: West Midlands
Age: 26
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Re: JS issue

what browser are you using cause it works fine here in FireFox
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jul 25th, 2007, 16:30
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: JS issue

It works at the moment in FF & IE but if you advance you clock to August and beyond it does not display any text.
Am I right about the month codes for JS though?
I am using FF to answer your question!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jul 25th, 2007, 16:46
Junior Member
Join Date: Jul 2007
Location: West Midlands
Age: 26
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Re: JS issue

Well sadly I made the mistake of forwading my clock to october and then 40 million reminders came up (really must stop my phone synching with the pc) but I see what you mean....

to answer your question the value returned by getMonth() is a number between 0 and 11. January is 0, February is 1 and so on.

I have adapted the code and it works ok here but again I cant forward my clock...

Code: Select all
<script>

var Digital=new Date()
var month=Digital.getMonth()

if (month <= 2){
    // month is between jan and march
    document.write("First Quarter of year");
} else if (month <= 5){
    // month is between april and june
    document.write("Second Quarter of year");
} else if (month <= 8){    
    // july and september
    document.write("Third Quarter of year");
} else {
    // otherwise its between oct and dec
    document.write("Fourth Quarter of year");
}
</script>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jul 25th, 2007, 17:45
Reputable Member
Join Date: Mar 2007
Location: UK
Posts: 305
Thanks: 0
Thanked 0 Times in 0 Posts
Re: JS issue

Sorted thank you all very much, until next time!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
js issue

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue in IE6 aholmes Web Page Design 7 Jul 13th, 2007 10:00
CSS issue in IE7 bluetech Web Page Design 6 Jul 3rd, 2007 15:36
css issue acrikey Web Page Design 4 May 24th, 2007 16:01
Help Odd Issue? drappendix Web Page Design 8 Aug 9th, 2006 17:53
IE issue Pheonix Web Page Design 2 Dec 2nd, 2005 21:58


All times are GMT. The time now is 21:04.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42