Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 2nd, 2006, 07:09 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default TD Color Change

This is an HTML / Javascript question...

What I am trying to do is make a very dynamic button set. Ideally I would like to have a partially transparent background image and then control the button color of the button with the bgcolor attribute of the cell. I have tried this with a gif and png image that have transparency, but it seems that when I use it as a background image, it loses the transparency. I am using Javascript to change the TD background color.

Does anyone have any experiences or ideas around this?

Thanks in advance,

Mike

Mike
EchoVue.com
__________________
Mike
EchoVue.com
  #2 (permalink)  
Old March 3rd, 2006, 03:40 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Echovue!!
Try this
trans1.jpg is the transparent image>change it to your reqd tranparent image
Click on the other button ,based on the button name background cell color is changed.

<table><tr><td id="imgcell"><img src="trans1.jpg" border=0 onclick="alert('Button Clicked')" width=100%

></td></tr>

<tr><td><input type=button value="blue" name="blue" onclick="changeColor(this.name)">
<input type=button value="darkgray" name="darkgray" onclick="changeColor(this.name)">
<input type=button value="cyan" name="cyan" onclick="changeColor(this.name)">
<input type=button value="red" name="red" onclick="changeColor(this.name)">
<input type=button value="black" name="black" onclick="changeColor(this.name)">
</td></tr>
</table>

<script>
function changeColor(currcolor)
{
obj=document.getElementById("imgcell")
obj.style.background=currcolor
}
</script>

Hope this will help you

Cheers :)

vinod


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change data of <TD> austinf Javascript 3 July 28th, 2006 05:32 AM
re: color change jack_in_black ASP.NET 2.0 Professional 0 July 11th, 2006 07:24 AM
change row color vivek_pon VS.NET 2002/2003 3 April 13th, 2006 01:42 PM
change <td> value onClick crmpicco Javascript How-To 2 August 23rd, 2005 07:31 AM
Color change possability? rolandatem VB How-To 2 November 19th, 2004 03:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.