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
2009-05-13 10:27:02
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
2009-05-13 10:35:55
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.
eteubert
2009-05-13 10:29:05
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.
2009-05-14 07:18:21
You have to put all your strings into quotes. "Aseat.png", "seat_new.png" etc.
eteubert
2009-05-14 19:49:23
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
2009-05-14 05:10:10