Hi, using Math.random(), I need to show one of six pictures every time I reload the page. I need to use the while loop too. So far I have this, but it only shows four of the six pictures I have. <script language="JavaScript"> var random = Math.random() ; var picnum = Math.round(random*4)+1; </script> </head> <script language="JavaScript"> document.write('<img src=picture/film'+picnum+'.jpg>') </script> HTML: Thanks for your help!
Of course it works... Unless you're using a very old browser it works flawlessly... create a html page with just this in it: <html> <head></head> <body> <script> var picnum = parseInt(Math.random() * 6) + 1; alert(picnum); </script> </body> </html> Code (markup): then open it, and refresh it many times... you'll always get a number between 1 an 6. If it still doesn't work for you, consider enabling javascript on your browser...