Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7640625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:43:02+00:00 2026-05-31T08:43:02+00:00

So, I’m working on a project for a motion-graphics class, wherein they teach us

  • 0

So, I’m working on a project for a motion-graphics class, wherein they teach us no JavaScript but then have us make a webpage using JavaScript. We’re told to use DreamWeaver, and that’s worked okay for most things, but I’m having trouble with one function in particular-

I want to be able to change an image multiple times when it is clicked. I’ve put the DW generated code below, basically I want sun.png to change to whitedwarf.png when clicked, and that works fine using the MM_swapImage() method. The rub is that I want to be able to click on the new whitedwarf.png and change it to a 3rd image (planet.png for the curious).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
body {
margin-left: 100px;
margin-top: 100px;
background-image: url(Images/startile.gif);
}
</style>
<script type="text/javascript">
function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src;     x.src=a[i+2];}
}
</script>
</head>

<body>
<img src="Images/sun.png" width="500" height="500" id="Image1" onclick="MM_swapImage('Image1','','Images/whitedwarf.png',0)" />
</body>
</html>

I’ve provided as much relevant info as I can, I have precisely no familiarity with JS, though I have programmed a good deal in Java, so I’m not completely illiterate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:43:03+00:00Added an answer on May 31, 2026 at 8:43 am

    “Use Dreamweaver”? Phooey on Dreamweaver. You don’t need no stinkin Dreamweaver.

    Start with a collection of images grouped inside a div or section (if you’re using HTML5)
    If CSS or Javascript are disabled, the images will show up normally, so you can still see them all.

    <div id="imgs">
    <img src="img.jpg" alt="My Image 1"/>
    <img src="img2.jpg" alt="My Image 2"/>
    </div>
    

    Then, when the page loads, hide all the images except one, and wire a click event to each image to hide itself and display the next one.

    var port_imgs, i;
        window.onload = function () {
                //get all the images in "#imgs"
            port_imgs = document.getElementById("imgs").getElementsByTagName("img");
               //loop through, hiding them all
            for (i = 0; i < port_imgs.length; i++) {
                port_imgs[i].style.display = "none";
                        //wire up the click event and do the magic
                port_imgs[i].onclick = (function (k) {
                    var r = function () {
                        this.style.display = "none";
                        if (k >= port_imgs.length) { k = 0 }
                        port_imgs[k].style.display = "block";
                    };
                    return r;
                })(i+1);
            }
                //un-hide (display) the first image so we're all set to go
            port_imgs[0].style.display = "block";
        }
    

    You can see a live example on my website, where I’ve employed exactly the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.