codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Change background within a table cell <td>  cahillb at 00:19 on Saturday, November 29, 2003
 

I am trying to create some javascript that will allow me to change the background image of a single cell within a table. In addition, I would like the user to be able to have a choice in their background image. This is my current code...it is capable of changing the background image but does so for the whole body of the webpage. Any ideas?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
.bgimages img {cursor:hand}
</style>
<script language ="JavaScript1.2">
<!--
function tile(){
if(!document.all)
return
var source=event.srcElement
if(source.tagName=="IMG")
document.body.style.backgroundImage="url("+source.src+")"
}

function restore(){
document.body.style.backgroundImage=''
}
</script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><img src="/forum/Images/Pop20Up20Art20Images/Almost_Sunset_copy.gif" width="390" height="352" align = "left"></p>
<table width="30%" border="1" cellpadding="2" cellspacing="2">
<tr>
<td width="10%"><font color="#000000">Title:</font></td>
<td width="20%"><font color="#000000">Almost Sunset</font></td>
</tr>
<tr>
<td width="10%" align="left"><font color="#000000">Artist:</font></td>
<td width="20%"><font color="#000000">Barbara Balthazor </font></td>
</tr>
<tr>
<td width="10%"><font color="#000000">Size:</font></td>
<td width="20%"><font color="#000000">24'' x 30''</font></td>
</tr>
<tr>
<td><font color="#000000">Price:</font></td>
<td><font color="#000000">$0.00</font></td>
</tr>
<tr>
<td>Shipping:</td>
<td>$50.00</td>
</tr>
</table>
<form name="almostSunset" method="post" action="customerInfo.html">
<input type="submit" name="almostSunset" value="Reserve">
</form>
<p align="center"><u>Choose a backdrop</u></p>
<div align="center"><span class = "bgimages" onClick="tile();event.cancelBubble=true"><img src="/forum/Images/backgroundblackgrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundbluegrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundbrowngrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundgrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundGrainTeal.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundgraygrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundgreengrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundorangegrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundpurplegrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundyellowgrain.gif" width="25" height="25" hspace="0" vspace="0"><img src="/forum/Images/backgroundwhite.gif" width="25" height="25"></span></p></div>
<p>  </p>
</body>
</html>









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  XML- Passing parameters are Latitude and Longitude.
•  Re: Format Date time issue....
•  Re: How to freeze the web page when displaying progress bar?
•  Re: Help! IFrames!
•  Re: Help: Trouble with z-Index and SELECT lists
•  Re: HOW CREATE LINE CHARTS IN ASP.NET
•  How to store and retrieve document into database
•  Re: text field multiple
•  Re: after updation of a table open another program .. need help


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005