Hi,
Goal of my script: Insert one of four images from an array into an html document without using onLoad()
[CODE]
function get_random() {
//rand function
var ranNum= Math.floor(Math.random()*4);
return ranNum
}
function randomFoto() {
var theFotoIs = get_random()
var muchoFotos = new Array(4)
muchoFotos[0] = “header3.jpg”
muchoFotos[1] = “headerBaker.jpg”
muchoFotos[2] = “header2.jpg”
muchoFotos[3] = “header.jpg”
document.write(muchoFotos[theFotoIs])
}
The script in the HTML is this:
[CODE]
<script language=”javascript”>
document.write(‘<img src=’ + randomFoto() + ‘>’)
document.write(‘</img>’)
</script>
The result that I am getting is the file name in the array (i.e. header3.jpg) being printed to the page rather than the html being processed by the browser and I end up with the picture not showing up.
I am guessing there is a very obvious mistake that I have made, I hope so at least. Thank you for help. I do not have the page live so I can not provide a url at this time. Sorry. The code has been tried in FireFox and IE but works in neither.
Thanks again.