|
|
|
|
![]() ![]() |
![]() |
Post
#1
Jul 21 2005, 04:44 PM
How To: Change An Image When A User Clicks On It using both php and javascript - a powerful combination I have seen quite a few how tos offering a method of doing this but none of which resembled my method of making use of both php and javascript. This code is fairly repetitive and most of the functions are easy to pick-up if you haven't heard of them before. Here it is...
If you want to see an example of this code, click here So that's it. I'll understand if this gets deleted because of the tutorial like this but I'll just thought I'd share my knowledge. Any questions/comments? |
![]() |
Post
#2
Jul 21 2005, 05:30 PM
Thanks for the tutorial. This is very interesting. But why doesn't it stay changed when you click it? You have to click and hold to keep it changed. Gj |
![]() |
Post
#3
Jul 21 2005, 05:39 PM
QUOTE(KuBi) But why doesn't it stay changed when you click it? You have to click and hold to keep it changed. Whoops! Misread your question. That's to create the effect that you're actually clicking the button, not just moving your mouse down. Could a mod please delete my previous post, although it may answer a question for someone. [note=BuffaloHELP]Merged instead of deleting.[/note] |
![]() Group: Admin
Posts: 3,646 Joined: 23-April 05 From: Trap17 storage box Member No.: 6,042 myCENT:90.30 |
Post
#4
Jul 21 2005, 06:52 PM
I think tutorial that does not work yet should not be approved until it works as it should be. I am looking at the site and nothing happens when I click on either images. And the link you provided at the end "Break the url to one of the images" says the following files cannot be found. The image should be changed to something else when I click on it, is that right? Wait...it took about 4 minutes for the other picture to be downloaded. Should that take this long to download the second image? |
![]() |
Post
#5
Jul 21 2005, 07:07 PM
QUOTE(BuffaloHELP @ Jul 21 2005, 07:52 PM) I am looking at the site and nothing happens when I click on either images. Wait for a few seconds give your browser time to load the image. The change onMouseDown is immediate, the loading isn't. QUOTE And the link you provided at the end "Break the url to one of the images" says the following files cannot be found. That was the point of the link QUOTE The image should be changed to something else when I click on it, is that right? Right and it does. QUOTE Wait...it took about 4 minutes for the other picture to be downloaded. Should that take this long to download the second image? If you connection is slow and the image is big (one of them is only 1.5kb) then it will take time because it's has to load the image. I'm running on 56k with 8 other internet windows open and it only took about 0.5 seconds the first time. |
![]() Group: Admin
Posts: 3,646 Joined: 23-April 05 From: Trap17 storage box Member No.: 6,042 myCENT:90.30 |
Post
#6
Jul 21 2005, 07:12 PM
QUOTE(cmatcmextra @ Jul 21 2005, 03:07 PM) If you connection is slow and the image is big (one of them is only 1.5kb) then it will take time because it's has to load the image. I'm running on 56k with 8 other internet windows open and it only took about 0.5 seconds the first time. [right][snapback]163886[/snapback][/right] I have DSL with TRAP17 server ping timed at 56ms. I don't think it's my connection issue. When I click on an image, the status bar displays "waiting for cmatcme.trap17.com... And why does the address bar show trap17.cmat?fileid=1&accessid=0hunm7fcvng5dfglokmnbdsa17hgfvbmnjklopiurewqazx along side? Is it possible that you provided your secure link? Is that why it's taking some time to load? The link was provided by your sample link. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 283 Joined: 10-October 04 Member No.: 1,637 |
Post
#7
Jul 22 2005, 12:55 AM
umm yes it's working but where to use this.. it can be easily done in css with a few line if you only wanted to switch the two images or more. but at least it's working so nice work. 5/10 rating |
![]() |
Post
#8
Jul 22 2005, 06:27 AM
QUOTE(badinfluence @ Jul 22 2005, 01:55 AM) umm yes it's working but where to use this.. it can be easily done in css with a few line if you only wanted to switch the two images or more. but at least it's working so nice work. 5/10 rating [right][snapback]163976[/snapback][/right] True and I could start about doing this, but with both javascript and php there are many ways you could set about customizing and alerting the script: Change... CODE <a onMouseDown=\"changeImage('imga','" . $i . $imgayes . "')\" onMouseUp=\"changeImage('imga','" . $i . $imgano . "')\"> \n <img src=\"" . $i . $imgano . "\" alt=\"\" name=\"imga\"> \n </a> ... To .... CODE Click <a onMouseDown=\"changeImage('imga','" . $i . $imgayes . "')\" onMouseUp=\"changeImage('imga','" . $i . $imgano . "')\"> here </a> to change the image below <br> <br> \n <img src=\"" . $i . $imgano . "\" alt=\"\" name=\"imga\"> \n And you will be able to click on "here" to change the image to change the image rather than clicking on the actual image itself. This script could be used on a navigation system on a website but you can adapt it and use it in many other places |
![]() ![]() ![]() ![]() Group: Members
Posts: 62 Joined: 11-July 05 Member No.: 9,266 |
Post
#9
Jul 25 2005, 06:10 PM
Why making it this difficult? Simply: CODE <img src="img.jpg" onMouseOver="this.src='img2.jpg'" onMouseOut="this.src='img.jpg'"> I think thats way easier |
![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 121 Joined: 27-April 05 Member No.: 6,270 |
Post
#10
Jul 28 2005, 04:55 AM
wow i thought noone was going to post that, the way sachavdk posted works MUCH better
|
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | ||
|---|---|---|---|---|---|---|
![]() |
4 | Echo_of_thunder | 108 | 11th November 2008 - 04:05 PM Last post by: Echo_of_thunder |
||
![]() |
17 | harad | 1,126 | 3rd August 2004 - 11:40 PM Last post by: MSTR |
||
![]() |
13 | galexcd | 848 | 14th August 2007 - 01:25 PM Last post by: Galahad |
||
![]() |
9 | psp-playstation | 691 | 26th August 2004 - 02:06 PM Last post by: redsky |
||
![]() |
3 | frazmi | 1,374 | 6th August 2006 - 02:20 AM Last post by: FallenSage |
||
![]() |
3 | Alpha | 697 | 18th August 2004 - 11:40 AM Last post by: odomike |
||
![]() |
10 | ill | 908 | 19th August 2004 - 01:29 PM Last post by: odomike |
||
![]() |
2 | Raptrex | 280 | 21st August 2004 - 04:09 PM Last post by: OpaQue |
||
![]() |
2 | truman69 | 393 | 29th May 2006 - 10:14 AM Last post by: Avalon |
||
![]() |
12 | cragllo | 929 | 25th August 2004 - 08:09 AM Last post by: cragllo |
||
![]() |