Javascript Random image shows 2 images at once?

Posted on 2007-08-01
Last Modified: 2010-04-16
One of my designers is trying to make something simple work - and is using the following code-- the goal is:  each time the page is refreshed, a different image will appear. (there are only two images)

What is happening is that when page is refreshed, both images show - instead of one. Can you tell what is wrong?  

<table width="771" height="341" border="0" align="center" cellpadding="0" cellspacing="0">
<td width="771"><img src="../Documents/QuoVardis/QV_web_07/images/oasis.jpg" width="771" height="341"></td>

<script language="JavaScript1.1">
document.Quo Vadis Travel.src="../Documents/QuoVardis/QV_web_07/images/DSCN1599_crop.jpg"+Math.round(Math.random()*6+.5)+".jpg";
Question by:webguy62
    1 Comment
    LVL 58

    Accepted Solution

    The script is trying to change the image with ID as "Quo Vadis Travel". The spaces in the ID would make this statement invalid. So if you check the javascript errors in your browser, you should see error. Also the HTML you posted is not being affected as there is nothing with that ID in it. If you want us to make suggestions, post where exactly you want that image to go and what are the exact image names.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
    Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
    The viewer will learn how to count occurrences of each item in an array.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now