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
  #11 (permalink)  
Old 02-21-10, 12:52 PM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
ok as soon as i access that site i will paste that table html to u thanks for ur time i will try to post it by 2morrow
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #12 (permalink)  
Old 02-23-10, 06:59 PM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
hi this is the html
HTML Code:
 <table width="100%" border="0" cellpadding="2" cellspacing="2">
	<img height="224" border="0" width="694" src="http://xyz.com/abc.jpg">
</td>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #13 (permalink)  
Old 02-23-10, 10:44 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Hello naumeer,

wirehopper was trying to be helpful, but he didn't know you were having a hard time understanding HTML as well as Javascript.
The last piece of code you posted was incomplete code for a table in HTML.
As soon as wirehopper saw that, he realized he would have to write the code for you, and he didn't really want get involved and I don't blame him.
We aren't here to teach you how to write HTML, which is the basics you will need to continue to write any program.
But I am a bit more generous and I will help you a little bit more.

The following code sets up a basic HTML page, which by far is not all that you may desire for your page.
Like including a basic doc type declaration, which isn't absolutely necessary but something to consider.

With all that said, here is the code.

I start with an <html> tag,
then a <head> tag.
After the <head> tag I have included a <script> section which has a Javacript function with a Javascript routine.
This Javascript function will load an image into an HTML <image> object (or element, if you prefer).
Then a closing </script> tag.
Then a closing </head> tag.
Then a <body> tag.
Now after the <body> tag I have setup a basic HTML table which includes one row with one cell.
Then I end the document with closing </body> and </html> tags.

To run the Javascript function when the page loads, I used the onload event listener in the <body> tag.

Example:
HTML Code:
<html>
<head>
<script type="text/javascript">
function loadImage()
{
 var monthImages = new Array("jan.jpg","feb.jpg","mar.jpg","apr.jpg","may.jpg","jun.jpg","jul.jpg","aug.jpg","sep.jpg","oct.jpg","nov.jpg","dec.jpg");
 var d = new Date();
 document.getElementById("banner").src="http://xyz.com/" + monthImages[d.getMonth()];
 document.getElementById("banner").alt="http://xyz.com/" + monthImages[d.getMonth()];
 }
</script>
</head>
<body onload="loadImage();">
<table width="100%" border="0" cellpadding="2" cellspacing="2">
 <tr>
  <td><img id="banner" src="http://xyz.com/jan.jpg" alt="http://xyz.com/jan.jpg" height="224px" border="0" width="694px" /></td>
 </tr>
</table>
</body>
</html>
__________________
Jerry Broughton

Last edited by job0107; 02-23-10 at 11:11 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
The Following User Says Thank You to job0107 For This Useful Post:
wirehopper (02-24-10)
  #14 (permalink)  
Old 02-26-10, 10:37 AM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
thanks i will check this script

Last edited by naumeer; 02-26-10 at 10:39 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #15 (permalink)  
Old 02-26-10, 10:56 AM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
unable to make this work shows a table but its empty with pictures name rolling like xyz.com/jan.jpg, xyz,com/feb.jpg etc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #16 (permalink)  
Old 02-26-10, 07:20 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by naumeer View Post
unable to make this work shows a table but its empty with pictures name rolling like xyz.com/jan.jpg, xyz,com/feb.jpg etc
Your the one that used xyz.com as an example.
HTML Code:
<img height="224" border="0" width="694"  src="http://xyz.com/abc.jpg">
Put in your URL.
HTML Code:
document.getElementById("banner").src="http://xyz.com/" + monthImages[d.getMonth()];
 document.getElementById("banner").alt="http://xyz.com/" + monthImages[d.getMonth()];
And if the names in this array aren't correct, change them to the correct names.
HTML Code:
var monthImages = new Array("jan.jpg","feb.jpg","mar.jpg","apr.jpg","may.jpg","jun.jpg","jul.jpg","aug.jpg","sep.jpg","oct.jpg","nov.jpg","dec.jpg");
__________________
Jerry Broughton
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #17 (permalink)  
Old 02-26-10, 09:11 PM
naumeer naumeer is offline
Newbie Coder
 
Join Date: Feb 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
the image worked but whatever i insert in this table that image is appearing
HTML Code:
<td><img id="banner" src="http://xyz.com/jan.jpg" alt="http://xyz.com/jan.jpg" height="224px" border="0" width="694px" /></td>
i have changed var monthimages = new Array( ) into my images name which r on ftp and the source in
HTML Code:
document.getElementById("banner").src="http://xyz.com/" + monthImages[d.getMonth()];
 document.getElementById("banner").alt="http://xyz.com/" + monthImages[d.getMonth()];
from where the images r coming the folder now do i have to insert every image with table for img src which i inserted above like all 12 banner images and when i change my date on my system changes of the banner should work automatically? sorry im kinda new sorry for the mess and yea i tried to test it through my system in dreamweaver

Last edited by naumeer; 02-26-10 at 09:31 PM.
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:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.