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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

choosing a color from a pop-up 1

Status
Not open for further replies.

ilmaggy

Programmer
Jan 4, 2005
11
NL
Hi,

I made a pop-up with a colour palette in which users can select a color. The color code is then 'sent' back to the main page in a text field of a form.
This is the script I used:
the pop-up:
function r(hval)
{
opener.document.formname.fieldname.value=hval;
self.close();
}

the main page:
<FORM NAME="formname" action="action.php" method="POST">
<input type="text" name="fieldname" value="">
</form>

But now I want the selected color to be the background color of a table instead of the color code in the textfield.
To make it the background color of the whole page i can use opener.document.bgColor but I couldn't find the right piece of javascript for only the background color of a table or cel.
Could anyone help me with this?
Thanking you in advance,
ruben.
 
Here:
Code:
function returnColor(clr)
{
  opener.document.getElementById('cell').style.backgroundColor = clr;
}
// opener
<table>
 <tr>
  <td id="cell"></td>
 </tr>
</table>

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top