Current location: Hot Scripts Forums » General Web Coding » JavaScript » How To Change Banner Automatically When Month Changes.


How To Change Banner Automatically When Month Changes.

Reply
  #1 (permalink)  
Old 02-20-10, 06:43 AM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
How To Change Banner Automatically When Month Changes.

Hi for eg. if i have 12 banners for my site naming jan-dec.jpg 1 banner for each month i want to change those banners automatically when month changes like if its January 1 then jan.jpg should display if its feb 1 then feb.jpg and so on till dec. Need simple script to make it work
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-20-10, 11:34 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
JavaScript getMonth() Method
JavaScript String Object

bannername=substr(month[d.getMonth()],0,3).toLowerCase()+'.jpg';

Not tested.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-20-10, 02:26 PM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
im new to this =/ im finding it hard to make a script =/ lets suppose if all my images r named like jan.jpg, feb.jpg....till dec.jpg and when each month changes that month banner should replace respectively.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-20-10, 02:49 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
HTML Code:
<img id="banner" src="jan.jpg" />
<script type="text/javascript">
bannername=substr(month[d.getMonth()],0,3).toLowerCase()+'.jpg';
document.getElementById('banner').src=bannername;
</script>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-20-10, 04:54 PM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
ok so if i copy paste this script it shall work? it will replace 12 banner's according to month and should i just copy paste this whole script or do i need to add anything more?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 02-20-10, 09:57 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You need some HTML ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 02-20-10, 10:34 PM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
hmm should it be something like this then
HTML Code:
<img id="banner" src="jan.jpg" />
<img id="banner" src="feb.jpg" />
<img id="banner" src="mar.jpg" />
<img id="banner" src="apr.jpg" />
<img id="banner" src="may.jpg" />
<img id="banner" src="jun.jpg" />
<img id="banner" src="jul.jpg" />
<img id="banner" src="aug.jpg" />
<img id="banner" src="sept.jpg" />
<img id="banner" src="oct.jpg" />
<img id="banner" src="nov.jpg" />
<img id="banner" src="dec.jpg" />
<script type="text/javascript">
bannername=substr(month[d.getMonth()],0,3).toLowerCase()+'.jpg';
document.getElementById('banner').src=bannername;
</script>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 02-20-10, 10:52 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Do you have an HTML page?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 02-21-10, 04:54 AM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
yea i do <<<removed link>>> for now it has expired holidays banner i want to put it there.

Last edited by wirehopper; 02-21-10 at 08:57 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 02-21-10, 08:58 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Please post the HTML around the banner. Use View source and find the <img> tag that brings the banner in.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks

Tags
banner, date, script


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] DataGridViewComboBoxColumn change to automatically update DataGridView tim8w Windows .NET Programming 1 01-25-10 01:34 AM
Change Banner After x amount of seconds toronto905 JavaScript 2 07-16-09 01:12 AM
Cheap Banner ads for sale as low as ~ $15 per month Tranix™ Traffic Exchange 1 01-29-06 03:47 PM
change 1 month to 1 day?? puzzele PHP 1 12-15-05 07:32 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 11:15 AM


All times are GMT -5. The time now is 10:48 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.