dsagrera
02-24-2008, 06:04 AM
Hey people!
I'm new at javascript and i'm really stuck with something that (I think) should be an easy thing to do. I'll explain:
I have an image, let's call it IMAGE_1. When i do a click on it, it should change to IMAGE_2, but when i click on it again, it should change to IMAGE_1 again and so on...
I tought it was easy, but my knowledge in javascript is not enough to finish it... I've used logic so far, but no luck, here's the code:
<img src='/imagenes/turnos/IMAGE_1.gif' width='10' height='10' name='disponible' id='disponible' border='0' onClick="javascript:if(this.src='/imagenes/turnos/IMAGE_1.gif'){this.src='/imagenes/turnos/IMAGE_2.gif';}else{this.src='/imagenes/turnos/IMAGE_1.gif';}">
The first part works great, IMAGE_1 changes to IMAGE_2 on the first click, but i can't make it work to change to IMAGE_1 when I click on it again.
It's not working after 2 hours of testing all sort of things... any ideas? Thanks in advance!
I'm new at javascript and i'm really stuck with something that (I think) should be an easy thing to do. I'll explain:
I have an image, let's call it IMAGE_1. When i do a click on it, it should change to IMAGE_2, but when i click on it again, it should change to IMAGE_1 again and so on...
I tought it was easy, but my knowledge in javascript is not enough to finish it... I've used logic so far, but no luck, here's the code:
<img src='/imagenes/turnos/IMAGE_1.gif' width='10' height='10' name='disponible' id='disponible' border='0' onClick="javascript:if(this.src='/imagenes/turnos/IMAGE_1.gif'){this.src='/imagenes/turnos/IMAGE_2.gif';}else{this.src='/imagenes/turnos/IMAGE_1.gif';}">
The first part works great, IMAGE_1 changes to IMAGE_2 on the first click, but i can't make it work to change to IMAGE_1 when I click on it again.
It's not working after 2 hours of testing all sort of things... any ideas? Thanks in advance!