Forums

This topic is locked

Changing property of dynamic images when clicked?

Posted 13 Aug 2009 16:49:54
1
has voted
13 Aug 2009 16:49:54 Mick Tomlinson posted:
I have a 'clients' page where the info about the particular client comes into a div when the logo image is clicked (Ajax).

What I'm wanting to do is change the border property of the clicked image so that it appears selected. Each of the images is assigned an id dynamically ('pic_<?php echo $row_rsClients['client_id']; ?>'), so I can target one image with:
<.....  onload="MM_changeProp('pic_<?php echo $row_rsClients['client_id']; ?>','','borderColor','#000','IMG')"  />

which works to change that one. However, I don't know how to switch the other ones back to original state when you click on a new logo. I can do it with a static site by changing all the images the MM_changeProp, but can't figure it out with dynamic data.

Any suggestions?
Thanks
Mick

Replies

Replied 14 Aug 2009 10:02:47
14 Aug 2009 10:02:47 Patrick Julicher replied:
Hi Mick,

Isn't this something that could better be done with CSS styles (link, active, hover, visited?)

Kind regards, Patrick
Replied 14 Aug 2009 13:56:35
14 Aug 2009 13:56:35 Patrick Julicher replied:
Hi Mick,

There are four states that a hyperlink can be in. Normal, Hover (when the mouse pointer is over the link), Active (when the link is clicked), and Visited. CSS allows you to control each state in any way you see fit.
If you are tryin to have the border change color when the logo is clicked, you could use the Active state. The border will change color again when the mouse button is released!
If you want the bordercolor to remain changed untill something else is clicked, CSS is not what you should use. Unfortunately I wouldn't know how to do this in PHP, since I only use ASP.

Kind regards, Patrick
Replied 17 Aug 2009 05:49:18
17 Aug 2009 05:49:18 huyen ptt replied:
thanks for your information
Replied 17 Aug 2009 13:24:27
17 Aug 2009 13:24:27 huyen ptt replied:
hi
thanks alot for your post
Replied 14 Oct 2009 12:38:06
14 Oct 2009 12:38:06 Alan C replied:
you could change the css class of the appropriate element with javascript, take a look at jquery which can do this really easily once you get the hang of it

Reply to this topic