--=====================_6757076==_
Content-Type: text/plain; charset="us-ascii"; format=flowed
Hi there,
I did something like that a long time ago. I have some source, but it might
not be very up-to-date. It's from my "early-learning-years" ;-)
Maybe this can be done way more efficient.
The source below draws a table of 8 columns and 6 rows, each having a
different color, based on the value in the array testArray.
Each cell contains a tiny gif, called spacer.gif, which is sized to 10 by
10 pixels. Of course you could without the spacer.gif, but this is just an
example.
Each spacer.gif is linked to a JavaScript function, called doSomething. In
my example the function does not exist. However, you could for example, set
a hidden form field to the value of the incoming parameter. If you combine
this with a set of radio buttons and hidden form fields for background and
font color, you can re-use the palette for multiple colored items.
To get your user's choices to the database, you'll need to submit the form.
So you'll need something like an apply or save button which submits the
hidden form-fields to the server, or submit the form from the doSomething
function directly.
You can expand this example by enlarging the array and by looping with p
and i a bit longer. Or by changing the way you write the table / palette.
This is just an example.
This isn't a true color picker like in Windows (you can't select any
arbitrary colors) but it comes close.
Imar
P.s. If the table looks really small, make sure the image "spacer.gif"
exists. It must be a completely transparent gif, and it shouldn't be too large.
<SOURCE CODE>
<HTML>
<BODY>
<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="2">
<TR>
<SCRIPT LANGUAGE="JavaScript">
testArray = new Array();
testArray = ([
'FF9999',
'FFFFEF',
'66FF99',
'00FF66',
'99FFFF',
'3399FF',
'FF66CC',
'FF00FF',
'FF0000',
'FFFF00',
'33FF33',
'66FF33',
'00FFFF',
'336699',
'660099',
'FF33FF',
'730D0D',
'EFBD00',
'33FF00',
'006666',
'0000AA',
'6666CC',
'990033',
'FF0099',
'660000',
'FF9933',
'007700',
'00AA00',
'0000FF',
'0000AA',
'990099',
'33CCCC',
'220000',
'660033',
'002200',
'001100',
'000077',
'000055',
'000033',
'000099',
'001100',
'999900',
'999966',
'777777',
'339999',
'CCCCCC',
'000000',
'FFFFFF',])
var q = 0;
for (p=0 ; p < 6 ; p++)
{
for (i=0 ; i < 8 ; i++)
{
document.writeln("<TD BGCOLOR='" + testArray[q] + "'><A
HREF='JavaScript:doSomething(\"" + testArray[q] + "\")'><IMG
SRC='SPACER.gif' WIDTH=10 HEIGHT=10 alt=" + '"' + "Click to change color to
" + testArray[q] + '"' + "BORDER='0'></a></td>");
q++;
}
document.writeln('</tr><TR>');
}
</SCRIPT>
</tr>
</table>
</body>
</html>
</source code>
At 12:45 PM 9/2/2000 +0100, you wrote:
>Hi friends,
>
>I am into a grave situation.
>I want to develop a color palette from which the user
>of the html-page can choose his/her favorite color
>and set it as the bkcolor of the page dynamically.
>
>How to change the bkcolor of the page dynamically has
>been taken care of by storing the hex-color format in a
>data-store.
>
>My problem is to create a color palette and to get the
>hex-color format from the same so that I can store in
>database.This is similar to the ColorDialog box in
>Windows.
>Can anyone please help me out???
>
>Have a nice week-end.
>Awating your response,
>
>Dipten Sarkar
>RSSoftware India Ltd,
>Calcutta,
>India-700091
>
--=====================_6757076==_
Content-Type: image/gif; name="SPACER.GIF";
x-mac-type="47494666"; x-mac-creator="4A565752"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="SPACER.GIF"
R0lGODlhAgACALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD/
/////yH5BAEAAA8ALAAAAAACAAIAQAQD8MkXADs
--=====================_6757076==_
Content-Type: text/plain; charset="us-ascii"; format=flowed
--=====================_6757076==_--