Jump to content

Image swaping


lamboman

Recommended Posts

I am new to javascript but have a fairly good understanding of it but am having a problem whith this. First I want to start off with loading a bunch of variables (they are images I am using as variables). Then I will have some buttons on one side of the sreen. Depending what button is pressed, it will display an image on the other side of the screen. I know i need to create an event for this to happen, but I am having a problem getting it right.

 

(this is for my variables, I know I need the event in here, but not having any luck)

 

<SCRIPT LANGUAGE="JavaScript">

<!--

if (document.images) {

  var pic1 = new Image();

  pic1.src = "..pic1.gif";

  var pic2 = new Image();

  pic2.src = "..pic2.gif";

}

 

//-->

</SCRIPT>

 

 

(this is my buttons on the one side of the page)

 

<button type="button" onclick="pic1()">Show Image 1</button>

<button type="button" onclick="pic2()">Show Image 2</button>

 

(and finnaly this is my action to display the image on the otherside, I just called it function1 for now)

 

<p id="function1">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.