Change An Image OnClick With Swap Back?

May 1, 2009

Let's say I have three images - one large image and two small thumbnails like so.

<p>
<img src="1_large.jpg" width="200" height="200" />
</p>
<p>
<img src="1_small.jpg" width="100" height="100" style="padding:0 5px;" />
<img src="2_small.jpg" width="100" height="100" />
</p>

Now, what I'm trying to achieve is: When you hover over the 2_small.jpg the 1_large.jpg temporarily changes to '2_large.jpg' until you mouseout then the image reverts back to '1_large.jpg'. If you click on the '2_small.jpg' thumbnail the '1_large.jpg' permanently changes to the '2_large.jpg' until you either hover/click on the '1_small.jpg' thumbnail.

View 2 Replies


ADVERTISEMENT

Onclick Swap Image Back And Forth

Aug 26, 2005

I don't have much experience with JavaScript, but this is so simple I can't understand why it doesn't work. Basically, when the user clicks the image of a gray arrow it switched to a green arrow and vice verca.

<SCRIPT TYPE="text/javascript">

function swaparrows() {
var x=document.images

x[0].src="../images/green-arrow.jpg";
}

</SCRIPT>

<img src="../images/gray-arrow.jpg"

But that only works once of course, I want users to be able to switch back as well, so I changed the function to what I thought would work:

function swaparrows() {
var x=document.images

if (x[0].src=="../images/gray-arrow.jpg") {
x[0].src="../images/green-arrow.jpg";
}

if (x[0].src=="../images/green-arrow.jpg") {
x[0].src="../images/gray-arrow.jpg";
} }

but it doesn't. I am used to PHP, but as far as I know IF statement works the same way.

View 4 Replies View Related

Nesting Onclick Image Swap Events And Image Mapping

Jul 24, 2009

I am trying to make a point and click javascript game. Basically what I want is to have one image displayed on screen at the start (room1.jpg). When you click on a door on that image, I have an onclick event to change the image to a new one that shows the door open (room1_a.jpg). What I want is that when you click the now open door, to display the next room in the game. The only solution I can think of is some sort of nested onclick event using several image maps, but I am fairly new to Javascript and I am not sure if that is possible. What it all comes down to is I want to display each incarnation of each room in the game in the same window without having to reload a new window for each room. I hope that makes sense, if not I can try and clarify. Below is the code I have so far. And as you can see all that does is display the open door when you click on the image. I have not done any of the image mapping yet.

[Code]...

View 2 Replies View Related

Image Swap OnClick Opens Image In Parent Window

Jul 26, 2010

I'm trying to use javascript to load an image on a webpage when another image is clicked on, just like an image gallery and just like this except I don't need any text: [URL] I copied the example above but when I click on the smaller image to load the larger one it works for a fraction of a second (I can see the image load in the right spot), but then the browser goes to the URL of the image instead (showing it on a blank page).

[Code]....

View 13 Replies View Related

Onclick Image Swap

Jul 3, 2006

Just want to swap an image (thumb) for a larger one - in the same spot - then click on the large image and go back to the small one.

Nothing I have tried works but I KNOW it can be done - can't it?

View 10 Replies View Related

OnClick Swap Image

Apr 17, 2005

How can I grab the image name "cat05_",add the proper ID to it, then swap the image? I cannot hardcode the name into an array as the page is dynamic so the image name changes on what page the user is on.

What I want it to do is load the image by the number that was pressed. onLoad would be cat05_1. So if number 2 was pressed cat05_2 would be pressed, cat05_3 would load if 3 was pressed. Code:

View 3 Replies View Related

Thum Gallry Swap Out With Main Image OnClick?

Dec 21, 2009

i have a thumbnail gallery of pictures on my page. I also have one area where i feature one of the gallery pics in larger format. Imagine a photography website, when a thumb is clicked, the larger pic is populated in the Feature section. Ideally this is all on one HTML page.

See code below.
<body>
<table width="770" border="0" cellspacing="0" cellpadding="0">

[code]....

View 1 Replies View Related

Text Swap - Change Each Image To Different Image On Mouseover

Jun 15, 2010

I'm failing to get a pure CSS way to achieve this, so trying JS. Several small images in a row, each different. Want mouseover to:

1. change each image to different image on mouseover (each image has its own mouseover image version).

2. produce different paragraph of text below row of images on each mouseover.

I can achieve it with mouseover on text links or on an image, but not with the two events, viz mouseover image swap + mouseover text swap. Would also want to be able to style the text.

View 4 Replies View Related

Image Swap - Change Would Become Quite Cumbersome

May 2, 2009

For instance, if I had 10 or more images to change this would become quite cumbersome.

Code:
<SCRIPT language="JavaScript">
<!--
if (document.images)
{
pic2on= new Image(100,25);
pic2on.src="story2.gif";
[Code]..

View 1 Replies View Related

OnClick Value Change And OnClick Value Change Back

Apr 16, 2009

I try to find working example, but no luck.I need this very simply javascript to onClick change value and second click change value back and third click change value again back and so on..

View 7 Replies View Related

Image Swap - Change On A Timed Event ?

Jan 16, 2011

Hey im working on a website and id like to put a image swap in so that the image will change on a timed event. Id like to make it so that when i click it it will bring me to anew page which isnt hard i just cant figure out the image swap.

View 1 Replies View Related

Switching Image Back And Forth Using OnClick?

Mar 27, 2011

I want to create the form button similar to this: [url]

I use an OnClick to switch the image but the if else statement just doent let me switch back to the original image, i not sure where i have gone wrong...

Below are the html and js thumnails:
[url]
[url]

View 1 Replies View Related

Swap Image - Change The Main Banner Part At The Top

Jun 16, 2009

i have a sliced page from photoshop. how i can change the main banner part at the top so that it gradualy changes over a period of time, i was thinking maybe a swap image thing, but not sure.

View 1 Replies View Related

Image Swap Based On Text Field Value Change?

Aug 17, 2011

i'm quite new to javascript and have an issue with an image swap script. I have three images that should change based on the value of a text field (total), however, there is only one image that is swapping. Please see the code below:

Code:
<html>
<head>
<script type="text/javascript">
//This is where we decare our function to validate the HTML form
function validateform()

[Code]...

View 4 Replies View Related

JQuery :: Change Background Image Then Do Call Back?

Jun 9, 2010

$('.collapse').click(
function(){
/*THIS*/ $('#loadingSymbol').css('background-image','url("ajax-loader.gif")');
triggerReset();
$('.identRow').each(

[Code]...

But /*THIS*/ and /*THAT*/ never happen. Is there a way of doing a callback, so that when the background image has changed, do the below functions. Then end with changing it to nothing again?

View 6 Replies View Related

ContentFlow - Change The ActiveItem Onclick To Just Bump It Over To The Next Image As If The Next Image Had Been Clicked

Jul 20, 2010

I am using ContentFlow from [URL] It is very well documented on their website. I got the whole thing working great on my site. What I don't know is how to change the ActiveItem onclick to just bump it over to the next image as if the next image had been clicked. As of right now it opens the image source in a self window. I don't want that. Can anyone give me a clue or maybe the whole answer on how to get it to click over to the next image? I believe the answer lies in the contentflow_src.js file.

View 6 Replies View Related

Change The Image Onclick?

Dec 1, 2010

I have this javascript code which I'm using for collapsible tables:

<html>
<head>
<script type="text/javascript">
function getItem(id)

[Code]....

So what I'm trying to do is display the image /path/to/plus when the table is closed, and then display the image /path/to/minus when the table is open.

View 8 Replies View Related

Change Image Using OnClick

Apr 28, 2004

I am trying to change up0.gif to up1.gif when a user clicks the "Click Me" button, but I am not bieng successful. Here is what I have so far:

View 2 Replies View Related

Change Image Src Value Onclick Not Working FF

Feb 8, 2010

<img id="who" class="who" src="who.jpg" alt="Warriors Chosen For Battle" title="Warriors Chosen For Battle">
<img id="chosen" class="selector" src="selector.jpg" alt="Click for next image"

[Code]....

Yeah so basically when I click on one of the selector images I want it to change the value "who" images src value. I'm making an image selector, it works fine in IE, but every other browser it refuses to do anything.

View 3 Replies View Related

Way To Change Border Of Image On OnClick

Jun 3, 2011

I am trying to add a border around the base they select and then when they select another one, I want the previous one to go away and then high light that one.This is my PHP code that outputs the bases:

$gender = $_GET['gender'];
// SQL Injection here?
$sql = "SELECT * FROM habases WHERE gender='".$gender."'";

[code]....

View 5 Replies View Related

Image Onclick Change Drop Down Value

Mar 30, 2011

i have a drop down menu called DDvehAttr

there are 7 values in this drop down (which is preloaded via backend) and the values are 1-7.

when the user clicks on an image i would like to alter the selected value in the DDvehAttr drop down with an onclick event.

there are 7 images in total and i would hope to do something like the following:

Code:
<img value="choice1" onclick="changevalue()" />
<img value="choice2" onclick="changevalue()" />
<script>
Function changevalue()

[Code]....

View 6 Replies View Related

Onclick Event To Change An Image To Text?

Oct 22, 2009

I want to use the onclick event to change an image to text. I'm working on a directory type website and want users to have to click on the image of a telephone in order to reveal the telephone number they are looking for. how do i do this? Also is there a way of tracking how many clicks each person gets?

View 1 Replies View Related

Onclick Change Thumbnail And Larger Image

Nov 19, 2010

*peeks into the ol' coding forum n' sooo glad its still just a here? the scenerio... there are four 'thumbs' in row 1...thumb1 thumb2 thumb3 and thumb4 there is one just a large? image in row 2 that changes when the respective thumb is clicked from row 1...AND @ the same time??? the thumb that was clicked just a changes? too... so now when the viewer just a clicks? thumb2....the big picture should change to BIG 2...the thumb1 should go back to its 'off' state n' thumb2 should be in its 'on' state...

/me found just a script? that does it for two thumbs...aka they change back when one or the other is click...BUTTT.../me cant just a copy? the script changing values to make it work when thumbs 3 and 4 are added into the mix...:O((( heres what /me has so far...

[Code].....

View 2 Replies View Related

Change DIV Text On Image Array Onclick Button?

Jun 25, 2010

I know it's been addressed before but I don't understand how to implement it on my code.

I want the content on the div 'text' to change every time a new picture loads on the image array. So the first picture would trigger 'THIS IS IMAGE 1' on the 'text' div, while the second image would display 'THIS IS IMAGE 2' and so on.

Here is my code,

Code:
<!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>

[Code]....

View 2 Replies View Related

Comparing Image Id's In Order To Change Opacity OnClick

Mar 9, 2010

I am using the following function in order to change an image opacity on a mouseover and mouseout. This function works fine but does not handle a onClick. What I mean by this is...... How can I create/alter the function to handle an onclick? I want to be able to click on an image (one of many) and have that image opacity change to 50%. There are other similar images whose opacity would need to remain at 100%. If one of those are clicked, that images opacity would then change, and the previous would restore to original value of 100% I thought about passing the clicked images id to the function but I can't find a way to compare an image id VS a passed image id.

[Code]...

View 2 Replies View Related

Swap URL On Image Swap

Mar 28, 2011

I am a complete novice with Javascript, but am trying to work out how I can get a button to swap to another image when clicked, and each image have a different URL attached. I want to use this to toggle the bgcolor of my page using this script:

Code:
<script type="text/javascript">
<!--
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
[Code]...

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved