I have a series of picture that I want to show. One random picture per session. I don't quite understand the random method provided in JavaScript. Could some one explain or suggest another solution?<br>
<br>
Thanks
The JavaScript <FONT FACE=monospace>math.random()</font> function simply generates a random decimal number between 0 & 1, inclusive. To change this to an integer value to be used in selecting a random picture, simply multiply the number generated by the number of pictures you have, then convert to integer...then you can call <FONT FACE=monospace>document.</font>image_name<FONT FACE=monospace>.src=eval(randomNumber)</font><br> This method will change the source of the first picture on your page to whatever location is assigned to the variable whose name matches the value of <FONT FACE=monospace>randomNumber</font><br><br>Ex:<br><br><FONT FACE=monospace><script language=JavaScript><!--;<br>var randomNumber=math.random()*5;<br><br>var 1="<A HREF="
[0].src=eval(randomNumber);<br>//--></script></font> <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= shared.freeservers.com/searchmaster.html>SearchMaster Interface...11-in-1</a><br>Wanting to learn Assembler; please e-mail me any tutorials or links for it that are useful to you
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.