# Random image in javascript problem

**URL:** <https://forum.kirupa.com/t/random-image-in-javascript-problem/112998>\
**Category:** Uncategorized\
**Created:** [June 14, 2004, 1:38am UTC](https://forum.kirupa.com/t/random-image-in-javascript-problem/112998 "2004-06-14T01:38:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![firstborn01](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/firstborn01/32/346_2.png) [@firstborn01](https://forum.kirupa.com/u/firstborn01)\
**Post date:** [June 14, 2004, 1:38am UTC](https://forum.kirupa.com/t/random-image-in-javascript-problem/112998/1 "2004-06-14T01:38:26Z")

</div>

before i ask this question i would like to preface it by saying that i can’t use php because doteasy’s $0 web hosting doesn’t support it unless you pay them extra money (which i don’t have)

so here we go…

in the header to my website i have a picture that is loaded at random every time the site is loaded. i would like to have it load only once and be the same throughout the many pages of my site but as far as i know, that is only possible with php. so i found a javascript code that will load a different picture everytime the page is loaded. it works fine but every once in awhile i get “undefined” where the picture should be. i checked all of my numbers and image names and everything but i can’t get it to go away. as of now, only the main page has the random images.

so what should i do?

my site is at [www.davekoen.com/version2](http://www.davekoen.com/version2) for now. when i get this working i am going to switch it to my main page.

thanks for your help.

dave
