Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnClick background change for individual table cells?

Status
Not open for further replies.

ID10T16

Technical User
Sep 22, 2000
160
US
I am trying to have each individual cell change it's background image when the link held inside it is clicked. I have wrote a script that changes the whole window's background. That's close to what I need, but I need it to do it to each individual cell. One line in my script that I believe is the key to alleviating this problem is: document.body.background... . It seems an alteration in that line would direct the event to occur in a specified cell. If anyone know's anything that could help, please give all help you can. I can be e-mailed at ID10T16@aol.com [sig][/sig]
 
I have found a solution to my own problem. It is quite simple in fact. If you would like to be able to use onMouseOver commands & such to change the background of an individual table cell, simply use this.
<td ONMOUSEOUT=&quot;this.background= 'Button1.gif';&quot; ...> make sure it is within the cell heading tag. I haven't figured out how to incorporate preloaded images into this, however I am working on this. If any of you know how I can incorporate preloaded images into this, please let me know. Hope this little bit of info helps someone.

PS: the line I use to incorporate preloaded images is
document.images[1].src=&quot;...&quot;
& added to the this.background line causes problems. [sig][/sig]
 
Try preloading the images in the typical way:

var bOn=new Image();
var bOff=new Image();
bOn.src=&quot;background_on.gif&quot;;
bOff.src=&quot;background_off.gif&quot;;

Then in your table cell:

<td background=&quot;background_off.gif&quot; onMouseOver=&quot;this.background=bOn.src;&quot; onMouseOut=&quot;this.background=bOff.src;&quot;>

Works in IE 4. By the way, does this agree with Netscape's DOM?

Regards, [sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top