SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Change BGcolor of table cell
Threaded View
-
Jul 30, 2003, 06:49 #1
- Join Date
- Sep 2002
- Location
- Walsall, UK
- Posts
- 1,911
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Change BGcolor of table cell
Hi All
I'm trying to change the background colour of a table cell (or layer - wotever) according to the figure entered into a text input. The idea is for a user to type in a hexadecimal colour code (eg. #ffffff) and see a preview of that colour in a box. The box is currently defined by a small table but this could be anything. The code I've currently got is this:
Code:<script language="JavaScript"> <!-- function updatePreview() { fgc = document.form1.fontcolour.value; document.getElementByID(prevFontColor).style.background = fgc; } --> </script> <input name="fontcolour" type="text" id="fontcolour" value="#000000" size="10" maxlength="7" onblur="updatePreview();"> <table width="14" height="14" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"> <tr> <td style="background-color: #000000" id="prevFontColor" width="12" height="12"> <img width="12" height="12" border="1" alt="" src="../files/spacer.gif"> </td> </tr> </table>
Cheers,
Bookmarks