|
Post by M o u s e on Nov 6, 2010 23:15:42 GMT
Alrighto so the code written for me here
<script type="text/javascript"> <!-- var rand = Math.round(Math.random()); var imgArray = ['img1url', 'img2url']; if (rand==1) { var img = imgArray[1]; }else { var img = imgArray[0] } document.write("<img src="+img+" />"); //--> </script>
it does not change everyday like once per day it changes like every 5mins. any ideas how to get it to change once per day?
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Nov 6, 2010 23:19:56 GMT
Ok would you rather a different image every mon, tue, wed, thu, fri, sat, sun or every day on the month 1-31st etc?
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Nov 6, 2010 23:26:20 GMT
If its for day of the week try this:
<script type="text/javascript"> var d=new Date(); var weekday=new Array(7); weekday[0]="http://images.proboards.com/new/buttons/movetopic.png"; //sunday image url weekday[1]="http://images.proboards.com/new/buttons/movetopic.png"; // monday image url weekday[2]="http://images.proboards.com/new/buttons/movetopic.png"; //tuesday image url weekday[3]="http://images.proboards.com/new/buttons/movetopic.png"; //wednesday image url weekday[4]="http://images.proboards.com/new/buttons/movetopic.png"; //thursday image url weekday[5]="http://images.proboards.com/new/buttons/movetopic.png"; //friday image url weekday[6]="http://images.proboards.com/new/buttons/movetopic.png"; //staurday image url
document.write("<img src='" + weekday[d.getDay()] + "' alt='Dayimage' />"); </script>
|
|
|
Post by M o u s e on Nov 6, 2010 23:26:30 GMT
nope it's just two pictures that I want it to be radomized between the two pictures.
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Nov 6, 2010 23:28:51 GMT
Ok just edit the code above with an alternate image url for each day...?
|
|
|
Post by M o u s e on Nov 7, 2010 0:08:48 GMT
okay so for this code I put the image in on lets say the first line sunday every sunday will be that picture or will it be random?
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Nov 7, 2010 0:10:36 GMT
this one will show that image and only the image in the line for each weekday
so every sunday the image listed for sunday will show
every tuesday the image for tuesday will show and so on etc...
|
|
|
Post by M o u s e on Nov 7, 2010 0:17:48 GMT
well I think I can make it work. I can just mix the pictures up every week
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Nov 7, 2010 0:21:46 GMT
If you want then an edition that goes by day on the month so from the 1st to the 31st and then you could mix them up along the way....there could be an even better option what exactly does this image show?
|
|
|
Post by M o u s e on Nov 7, 2010 0:26:38 GMT
well pretty the plot of this is that there is animal shelter on my site and I wanted so one day like a the animal shelter van is out kind like a dog catcher. so one picture is a van saying the van is out today and the other is a big red X saying no van today and I wanted to be randomized on days the van is out and days there not out.. image one- image two-
|
|
Cam
Administrator
[M:5000]
Posts: 6,381
|
Post by Cam on Nov 8, 2010 5:38:54 GMT
Still need help?
|
|
|
Post by M o u s e on Nov 9, 2010 5:47:57 GMT
Yus, I got the guy that made the Weather Code to make me another code and IT stil does not work every time you click it changes pictures.. starting to give up.
<script type="text/javascript"> <!-- var rand = Math.round(Math.random()); var imgArray = ['http://i912.photobucket.com/albums/ac321/Mouse1994/white_van-2-1.gif', 'http://i912.photobucket.com/albums/ac321/Mouse1994/redxmark23757-1.jpg']; var imgsrc = imgArray[rand]; document.write('<img src="'+imgsrc+'" />'); //--> </script>
Can this be explained to me-If you want then an edition that goes by day on the month so from the 1st to the 31st and then you could mix them up along the way
|
|
Dalton
Senior Poster
[M:0]
Posts: 68
|
Post by Dalton on Apr 1, 2011 17:16:56 GMT
Okay I think I understand what you want.
<script language="javascript" type="text/javascript"> <!--// // author: skemcin // description: random image generator - place this code exactly where you want the random image to be rendered. // necessary mods: you will need to do the following things to make this work as desired: // - change "_random/" to the relative or absolute path of the folder where you will store your random images - I highly recommend keeping these seperate from all other images as it makes it easier to maintain. // - change or remove "theme_fall_" to your desire. I use it to to uniquely identify a series of images that are related. It is prepended to the random number javascript create whihc in turn constructs the filename used to render/locate the image // - change or remove "width='150' height='100'" the width and height are optional - if you know all your images are the same dimensions, I would recommend keeping them. If, for whatever reason, you wish to have images that are a variety of sizes, then remove these so they are not physically constrained. // - convention - this is the most important thing!! most random scrips have you define the file names in the script - making it harder to change them around. This script relies on what I have found to be a typical habit and that is to simply name all your images the same name but adding a number on the end. // - change "27" to reflect the highest number assigned to your files. Since this is javascript, you must have a zero(0) image defined since that is where javascript begins to count image0.gif, image1.gif, image2.gif . . . random_num = (Math.round(Math.random()*27)); // example of a n image this would find is: http://www.yourdomain.com/_random/theme_fall_12.gif document.write("<img src='_random/theme_fall_" + random_num + ".gif' width='150' height='100' hspace='0' vspace='0' border='0'><br />"); //--> </script>
This is more like what you are looking for I believe.
(Source:http://w3schools.invisionzone.com/index.php?showtopic=9500)
|
|