473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Change Image on click.

59
Let's see i have two images.
Expand|Select|Wrap|Line Numbers
  1. $image1 = mysql_query('SELECT `image` FROM `images` WHERE `image`=`image1.jpg`");
  2. $image2 = mysql_query('SELECT `image` FROM `images` WHERE `image`=`image2.jpg`");
here i have, let's say $image1 showing with a image button, "image1button.jpg". When clicked either the $image1or the button, i want the image to change to $image2 and button to change to "image2button.jpg".

This should also work in reverse order. How can i go on about doing this? :)
Sep 8 '07 #1
5 3259
pbmods
5,821 Expert 4TB
CSS, I'm surprised. I would have thought that someone who's been on TSDN as long as you have would know to use CODE tags when posting source code. Bad!

[CODE=php]
PHP code goes here.
[/CODE]
Sep 8 '07 #2
cssExp
59
sorry forgot. I was in a hurry when i typed that. :) If you look at my other posts, you'll see i always use [code]
Sep 8 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

you need to call a function 'onclick' of the image and the button. inside this function you will refer to the img and button with document.getElementById(); so set ids to the elements :) ... inside the function it should look like this:

Expand|Select|Wrap|Line Numbers
  1. var img_node = document.getElementById('your_img_id');
  2. img_node.src = 'new_img_src.jpg';
go ahead and try something ... post back in case you have more questions about it or you need something to be more clarified ...

kind regards
Sep 8 '07 #4
cssExp
59
for some reason getElementById didn't work, but i did use its name and played with it till i got the result i wanted.

Thanks :)
Sep 8 '07 #5
gits
5,390 Expert Mod 4TB
?? ... did you set an id for your elements? ... however ... glad to hear you got it working ... post back to the forum anytime you have more questions ...

kind regards
Sep 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Christian Kusenbach | last post by:
Hello group! I've a problem with JavaScript and IMG-Objects. On my webpage I use a big image and several small images. If you click on a small image, it executes a JavaScript to change the...
2
by: Irvin Amoraal | last post by:
I am new to javascript coding. I am using some javascript code to change an image on an html page. I would like the user to click on the image to bring them to another page. I need to change an...
1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue. I have 3 images(I call them 1a-3a). when u...
2
by: Ben | last post by:
Hi. I have a button that change a number of images src's when I click a button. The src's are stored in an array and I just use document.src=pics to change the src of the image. However I want...
6
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick" (mouse up) change to the original image. Basically...
2
by: david | last post by:
When you right click on a file in windows, there is a property of type of file, which seems to associate this file with an application for it. For example, when you double click on a .doc file, the...
3
by: NeverwaY | last post by:
How can i make a button click change an image in a picture box? I basically have an image in my main Form, i want it to change when a button is clicked. -- <XML> <BEGIN:: DCSE-TRAINING> <END::...
6
by: Karl | last post by:
Hi, Ok so on a given page I have 4 text links: see it in black see it in blue see it in red see it in green using the standard swap image behavior, clicking on one of the above links
3
by: vj | last post by:
how to change images based on action. Even clicking changed images should do respective actions. and while displaying only one image at a time sholud get displayed. I am using three images for a...
9
by: ghjk | last post by:
change the background image when Button Click ====================================== I' developing site with php and postgres. It has menus list in the left side. and all are images(jpg) EX:Add...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.