Jump to content

Problem..Plz Help


murli800

Recommended Posts

hi all great coders..i have a problem..i want to change the color of status whenever it is clicked..for elaborating my problem more clearly i am attaching the screenshot of the problem...only color of first row status is changing..even if i am clicking the image of second row the color of first row image changes...i attached both the pics..and the php code...thanx in advance...

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/242039-problemplz-help/
Share on other sites

An ID must be unique- only used for one element. Here you're assigning it to every image, so the browser is just applying it to the first with that ID, as it isn't expecting there to be more than one. Instead of adding a number  to the end of the ID or something though, just pass the element's object to the function using the special JavaScript variable "this":

 

<img border="0" width="20" height="20" src="enable.jpg" onclick="change(this);"  />

 

"this" represents the current element's object; the "img" as it's represented internally within the DOM tree. Within the function add the parameter so that you can use it:

 

function change(obj)

 

Now instead of using getElementById(), you can simply use the variable "obj". For example:

 

obj.src="disable.jpg";

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/242039-problemplz-help/#findComment-1242995
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.