Random Javascript image and text button?
So I found this script and i give all props to the author but can anyone help me to add text to the random images. Also i need a button that will generate the random images/text not when you refresh the page but when your press the button and to not display any image/text till the button is pressed?
Thanks in advance.
[CODE]
<script language="Javascript">
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] = 'images'
image[1] = 'images'
image[2] = 'images'
image[3] = 'images'
image[4] = 'images'
image[5] = 'images'
image[6] = 'images'
image[7] = 'images'
image[8] = 'images'
image[9] = 'images'
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>
<form>
<p><input type="button" name="B1" value="Switch It Up" onclick="ranimage()"></p> </form>
[CODE]
|