Help - Search - Members - Calendar
Full Version: Javascript in HTML
HTMLHelp Forums > Programming > Client-side Scripting
I am using javascript to randomize the 9 images in html to appear differently each time the page is loaded!
I am so not sure where to begin and would appreciate any starters advice or help!

I know i need variables, but how do I make the 9 images to appear randomly each time..

Thanks for all your help

The code is below. As you can tell I have only introduced java as the script, I dont know what to do next. I think I need to use Math random or something...


<title>Shady Plants</title>
<span style="color:#f50">Shady</span>
<span style="color:#ff0">Plants</span>

            <p>Have you ever wondered why your plants just die when you do all the right things? It may be because your plants dont require too much sunlight
            (or the other way around). Shady plants are good for small gardens, and cramped places where the sun doesnt reach all the way. However, you can still
            grow beautiful plants like the ones below. It really just depends on your taste as to what you would like to grow. If you have a green thumb, you can
            try your hand at exotic flowers such as bleeding hearts, wild ginger, and fairy wings. Or, if you prefer regular shaped normal flowers, you can try
            Forget-Me-Nots, trillium, and creeping buttercups. If you like big and wide spreading flowers, you can plant brazilian plume, and blue buggleweed. And,
            if your looking to be inspired, try the beautiful Tiger Monkey flower. Good Look Flowering! Also, try to guess which name belongs to which flower,
            they are all pretty easy to unravel. </p>
        <div id="pictures">

        <img src="1.jpg" alt="flower" width="304" height="228" />
        <img src="2.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="3.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="4.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="5.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="6.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="7.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="8.jpg" alt="Pulpit rock" width="304" height="228" />
        <img src="9.jpg" alt="Pulpit rock" width="304" height="228" />
        <script type="text/javascript">
Christian J
QUOTE(htmlbeg @ Apr 17 2012, 03:09 AM) *

I am using javascript to randomize the 9 images in html to appear differently each time the page is loaded!

Then I move the thread to the JS forum.

Do you mean you want to shuffle the order of the images (with all of them visible), or do you want just one image visible at the time? Googling image random javascript should turn up lots of versions of at least the latter.

You can also use server-side script (e.g. PHP) for this.
I want to shuffle the order of the images each time.

I have to use java..its a requirement.
Christian J
Maybe this one can be used:

Unfortunately no images will be visible to users without JS.
Darin McGrew
And for the record, JavaScript and Java are completely different languages.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.