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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.