M
Mickey
Hi,
I am having trouble with a javascript.
The purpose of this script is to enable a user to click a generated
color cell in a table and the color code ie: #ffffff is returned to the
caller... ie: printed in a textfield on the calling page/form.
Presently, in Firefox.. this script will print the shell of a table
(just the borders...) and in IE I get nothing.
I would aprechiate it if someone had the time to look over this short
script (below) and perhaps suggest to me, where I am going wrong?
------------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!--
function setColor(sentcolor)
{
document.f.c.value=sentcolor;
opener.document.createStyle.bgLink.value = sentcolor;
}
function getColorTable()
{
// Color code table
c = new Array('00', '33', '66', '99', 'cc', 'ff');
// Start color table
t = '<table border="1" cellpadding="6"
style="border-collapse:collapse;">';
// Iterate red color
for (r = 0; r < 6; r++)
{
// Iterate green color
for (g = 0; g < 6; g++)
{
// Start color table row
t += '<tr>';
// Iterate blue color
for (b = 0; b < 6; b++)
{
// Get RGB (background) color code
L = '#' + c[r] + c[g] + c;
// Get alternative/tooltip text
A = L + ' = RGB('
+ parseInt('0x' + c[r]) + ', '
+ parseInt('0x' + c[g]) + ', '
+ parseInt('0x' + c) + ')'
;
// Get "inverted" RGB (foreground) color code
F = '#' + c[5 - r] + c[5 - g] + c[5 - b];
// Color table cell
t += '<td align="center"'
+ ' style="'
+ 'background-color:' + L + ';'
+ 'color:' + F + ';'
+ 'font-family:Courier New;'
+ 'cursor:hand;'
+ '"'
+ ' title="' + A + '"'
+ ' onclick="setColor(\'' + L + '\');"'
//+ ' onclick="add_smilie(\'' + L + '\');"'
//+ ' onmouseover="window.status=\'' + A + '\';"'
//+ ' onmouseout="window.status=\' \';"'
+ '></td>'
;
}
// End color table row
t += '</tr>';
}
}
return t;
}
//-->
</script>
</head>
<body bgcolor='#1E2C38'>
<form name="f"><input type="text" size="7" name="c" value=""></form>
<script type="text/javascript" language="JavaScript">
<!--
document.write(getColorTable() + '</table>');
//-->
</script>
</html>
---------------------------------------------------------------------------------------------------------------------------
Thanks in advance for your time.
Kind Regards,
Miky
I am having trouble with a javascript.
The purpose of this script is to enable a user to click a generated
color cell in a table and the color code ie: #ffffff is returned to the
caller... ie: printed in a textfield on the calling page/form.
Presently, in Firefox.. this script will print the shell of a table
(just the borders...) and in IE I get nothing.
I would aprechiate it if someone had the time to look over this short
script (below) and perhaps suggest to me, where I am going wrong?
------------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!--
function setColor(sentcolor)
{
document.f.c.value=sentcolor;
opener.document.createStyle.bgLink.value = sentcolor;
}
function getColorTable()
{
// Color code table
c = new Array('00', '33', '66', '99', 'cc', 'ff');
// Start color table
t = '<table border="1" cellpadding="6"
style="border-collapse:collapse;">';
// Iterate red color
for (r = 0; r < 6; r++)
{
// Iterate green color
for (g = 0; g < 6; g++)
{
// Start color table row
t += '<tr>';
// Iterate blue color
for (b = 0; b < 6; b++)
{
// Get RGB (background) color code
L = '#' + c[r] + c[g] + c;
// Get alternative/tooltip text
A = L + ' = RGB('
+ parseInt('0x' + c[r]) + ', '
+ parseInt('0x' + c[g]) + ', '
+ parseInt('0x' + c) + ')'
;
// Get "inverted" RGB (foreground) color code
F = '#' + c[5 - r] + c[5 - g] + c[5 - b];
// Color table cell
t += '<td align="center"'
+ ' style="'
+ 'background-color:' + L + ';'
+ 'color:' + F + ';'
+ 'font-family:Courier New;'
+ 'cursor:hand;'
+ '"'
+ ' title="' + A + '"'
+ ' onclick="setColor(\'' + L + '\');"'
//+ ' onclick="add_smilie(\'' + L + '\');"'
//+ ' onmouseover="window.status=\'' + A + '\';"'
//+ ' onmouseout="window.status=\' \';"'
+ '></td>'
;
}
// End color table row
t += '</tr>';
}
}
return t;
}
//-->
</script>
</head>
<body bgcolor='#1E2C38'>
<form name="f"><input type="text" size="7" name="c" value=""></form>
<script type="text/javascript" language="JavaScript">
<!--
document.write(getColorTable() + '</table>');
//-->
</script>
</html>
---------------------------------------------------------------------------------------------------------------------------
Thanks in advance for your time.
Kind Regards,
Miky