This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » Ajax & JavaScript » Changing property of dynamic images when clicked?
Reply

Changing property of dynamic images when clicked?

Mick Tomlinson
Member



Since: 17 Oct 2007
Posts: 8
Posted 13 Aug 2009 16:49:54

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

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
Patrick Julicher
Official Representative



Since: 04 Feb 2002
Posts: 1,208
Replied 14 Aug 2009 10:02:47
Hi Mick,

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

Kind regards, Patrick
Patrick Julicher
Official Representative



Since: 04 Feb 2002
Posts: 1,208
Replied 14 Aug 2009 13:56:35
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
huyen ptt
Member



Since: 16 Aug 2009
Posts: 2
Replied 17 Aug 2009 05:49:18
thanks for your information
huyen ptt
Member



Since: 16 Aug 2009
Posts: 2
Replied 17 Aug 2009 13:24:27
hi
thanks alot for your post
Alan C
Total freaking Member



Since: 04 May 2006
Posts: 473
Replied 14 Oct 2009 12:38:06
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

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency