...

View Full Version : Random Image Generator



CurtWRC
05-22-2005, 07:17 PM
Hi Everyone.

I recently found this random image generator code. However it when the images show it displays them in their full size. Is it possible to edit this code in a way so that the image size will be the same everytime? So that all images will be shown as 100x50 for example.

Thanks,
Curt


<script language="Javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var currentdate = 0
var core = 0

function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '

}
}

image = new StringArray(10)
image[0] = '0.gif'
image[1] = '1.gif'
image[2] = '2.gif'
image[3] = '3.gif'
image[4] = '4.gif'
image[5] = '5.gif'
image[6] = '6.gif'
image[7] = '7.gif'
image[8] = '8.gif'
image[9] = '9.gif'

var ran = 60/image.length

function ranimage() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(image[core])
}

document.write("<img src='" +ranimage()+ "'>")

//-->
</script>

CurtWRC
05-22-2005, 07:18 PM
Ive just noticed Ive put this in the wrong section. Sorry.

_Aerospace_Eng_
05-22-2005, 07:30 PM
It's fine, just don't cross post it will be moved accordingly.

<script type="text/javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var currentdate = 0
var core = 0

function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '

}
}

image = new StringArray(10)
image[0] = '0.gif'
image[1] = '1.gif'
image[2] = '2.gif'
image[3] = '3.gif'
image[4] = '4.gif'
image[5] = '5.gif'
image[6] = '6.gif'
image[7] = '7.gif'
image[8] = '8.gif'
image[9] = '9.gif'

var ran = 60/image.length

function ranimage() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(image[core])
}

document.write("<img width="xx" height="xx" alt="" src='" +ranimage()+ "'>")

//-->
</script>
It document.writes the image tag to the page, just add in the width and height that you desire there.

CurtWRC
05-22-2005, 07:44 PM
hmm...it says there is an undetermined string error or something like that. SO it isn't working.

I will keep trying.

Thanks for your help.

_Aerospace_Eng_
05-22-2005, 08:57 PM
That is my fault sorry, I wasn't thinking at the time.

<script type="text/javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var currentdate = 0
var core = 0

function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '

}
}

image = new StringArray(10)
image[0] = '0.gif'
image[1] = '1.gif'
image[2] = '2.gif'
image[3] = '3.gif'
image[4] = '4.gif'
image[5] = '5.gif'
image[6] = '6.gif'
image[7] = '7.gif'
image[8] = '8.gif'
image[9] = '9.gif'

var ran = 60/image.length

function ranimage() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(image[core])
}

document.write("<img width='xx' height='xx' alt='' src='" +ranimage()+ "'>")

//-->
</script>
It should be single quotes not double quotes.

CurtWRC
05-23-2005, 06:28 PM
Its working now :)

http://www.rallystuff.net/

Thanks a lot,
Curt

_Aerospace_Eng_
05-23-2005, 08:16 PM
John do you care to elaborate? What syntax exactly are you referring to?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum