tags:

views:

111

answers:

4

If I click on the image it should be changed the color of the part of the image.Then I want to replace the image.Can it be done using javasript? Pls help me.

+2  A: 

JavaScript can't change physical images like .jpg, .png or .gif (to my knowledge) But replacing images is easy.

document.getElementById("foo").src = "example.jpg";
Ólafur Waage
Unless you need to programmatically change the colour to a value determined at runtime that could have many options - just create several images for each colour and swap in the appropriately-coloured one using the Javascript above.If you preload the images via JS the change should appear to be instant.
Andrzej Doyle
A: 

If you mean changing the color of the clicked pixel, not, this is not possible with JavaScript only. But you can get the coordinates and pass them to a PHP script. In PHP you can change the image.

http://de2.php.net/manual/en/book.image.php

eteubert
Thanks for your reply.I try to do using this code.if(imagecopy ( Aseat.png , seat_new.png , 0 , 1 , 0 , 1 , 10 , 16 ))){ return Aseat.png; header("Location:Test1.html");imagegif(Aseat.png);imagedestroy(Aseat.png);imagedestroy(seat_new.png);}But I get error like this.Parse error: parse error in D:\xampp\htdocs\seat_planner\Testimage.php on line 20Line 20 of above code isif(imagecopy ( Aseat.png , seat_new.png , 0 , 1 , 0 , 1 , 10 , 16 ))){pls give me an instruction.
You have to put all your strings into quotes. "Aseat.png", "seat_new.png" etc.
eteubert
A: 

Unless i misunderstood i think you could probably place a transparent image above the image you wanted to change, thereby kind of changing the appearance of the image. I think i did something like this with prototype once.

doug
A: 

As for the color change, yes it can be done, you could probably cook something with SVG and the Canvas element and JavaScript using your image.

apphacker
I don't know about SVG and Canvas element.Pls tell me how can I use these for my propose.Actually I want to change the colour of the part of the image when click the mouse on that part.