check if the image is clicked

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
esandra
Forum Newbie
Posts: 24
Joined: Sun Aug 30, 2009 11:11 pm

check if the image is clicked

Post by esandra »

if this image is clicked:
<img src="images/del.png" width="15" height="15" onclick="hide(<?php echo $y;?>)">

this image should appear:
<img src="images/undo.png" width="20" height="20" onclick="show(<?php echo $y;?>)" title="undo">

2nd image won't replace the first one, it will appear somewhere else
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: check if the image is clicked

Post by mellowman »

this seems to be manageable via JavaScript not php.

Ill give you an example...The bases behind the code is that your updating the div with information and in this case updating it with a button. :D

<script>
function hide() { document.getElementById(div1).innerHTML = '<img src="images/undo.png" width="20" height="20" onclick="show()" title="undo">'; }

function show() { document.getElementById(div1).innerHTML = '<img src="images/del.png" width="15" height="15" onclick="hide()">'; }
</script>
<html>
<div id="div1"><img src="images/del.png" width="15" height="15" onclick="hide()"></div>
</html>
esandra
Forum Newbie
Posts: 24
Joined: Sun Aug 30, 2009 11:11 pm

Re: check if the image is clicked

Post by esandra »

thank you for your reply. i'd test this right away
Post Reply