Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old March 23rd, 2008, 12:40 PM   #1
Reputable Member
 

Join Date: Mar 2007
Location: UK
Posts: 309
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 acrikey is on a distinguished road
[SOLVED] What have I done wrong in this code?

I am trying to make this script change my banner jpg dependent on the month:

Code:
<script>

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

if (month <= 2){
    // month is between jan and march
    
    document.write[Winter]("<IMG SRC='fieldworks/images/img5.jpg'>");
} else if (month <= 5){
    // month is between april and june
    document.write[Spring]("<IMG SRC='fieldworks/images/img2.jpg'>");
} else if (month <= 8){    
    // july and september
    document.write[Summer]("<IMG SRC='fieldworks/images/img2.jpg'>");
} else {
    // otherwise its between oct and dec
    document.write[Autumn]("<IMG SRC='fieldworks/images/img3.jpg'>");
}
</script>
any ideas?
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 23rd, 2008, 01:28 PM   #2
Most Reputable Member
 

Join Date: May 2007
Location: Cornwall, England
Posts: 1,421
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Rep Altering Power: 0 Jack Franklin will become famous soon enough
Re: What have I done wrong in this code?

Are you getting an error or nothing at all? What is going wrong?
__________________
Yours is the Earth and everything that's in it
And - which is more - you'll be a Man my son!
Jack Franklin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 23rd, 2008, 01:48 PM   #3
Reputable Member
 

Join Date: Mar 2007
Location: UK
Posts: 309
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 acrikey is on a distinguished road
Re: What have I done wrong in this code?

blank screen

http://www.lightex.co.uk/fieldworks/season.html


Uername: Test
Pass: Webforumz
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 23rd, 2008, 03:07 PM   #4
New Member
 

Join Date: Oct 2007
Location: Sweden
Age: 30
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 aihazm is on a distinguished road
Re: What have I done wrong in this code?

write (in document.write) is a function not an array or an object, so you can't use [], you have tu use () :
document.write[], should be document.write() , and inside the paranthese yaou can put the string that you want to parse into the html document:
Code:
<script>
var Digital=new Date()
var month=Digital.getMonth()
if (month <= 2){    // month is between jan and march    
    document.write("<IMG SRC='fieldworks/images/img5.jpg'>");
} else if (month <= 5){
    // month is between april and june
    document.write("<IMG SRC='fieldworks/images/img2.jpg'>");
} else if (month <= 8){    // july and september
    document.write("<IMG SRC='fieldworks/images/img2.jpg'>");
} else {    // otherwise its between oct and dec
    document.write("<IMG SRC='fieldworks/images/img3.jpg'>");
}
</script>
But maybe you have a purpose in putting [Winter]...[Summer]-> can you explain?
aihazm is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 23rd, 2008, 03:16 PM   #5
Reputable Member
 

Join Date: Mar 2007
Location: UK
Posts: 309
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 acrikey is on a distinguished road
Re: What have I done wrong in this code?

still nothing
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 23rd, 2008, 03:18 PM   #6
Reputable Member
 

Join Date: Mar 2007
Location: UK
Posts: 309
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 acrikey is on a distinguished road
Re: What have I done wrong in this code?

it was a hint for me
acrikey is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 23rd, 2008, 07:39 PM   #7
Reputable Member
 

Join Date: Mar 2007
Location: UK
Posts: 309
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 acrikey is on a distinguished road
Re: What have I done wrong in this code?

Thank you guys, I have sorted it now, I had to put the whole url in in the end
acrikey is offline  
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

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
[SOLVED] Pop up pops up at the wrong time R8515198 JavaScript 3 October 5th, 2007 12:49 AM
What is wrong with my code acrikey Flash and ActionScript 9 July 30th, 2007 12:19 PM
What's wrong with this code?? Lexxi JavaScript 1 April 25th, 2007 09:07 PM
AAArrrgggg....what;s wrong with this code murf JavaScript 2 November 24th, 2006 08:50 PM
what is wrong with this code inusrat JavaScript 0 June 28th, 2006 09:18 AM


Search Engine Optimization by vBSEO 3.2.0 RC8