Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: CGI Colour Palette (Javascript Solution)

by BigLug (Chaplain)
on Aug 09, 2002 at 01:42 UTC ( [id://188801]=note: print w/replies, xml ) Need Help??

in reply to CGI Colour Palette

Although this is a JS solution, it could be modified to perl. The reason its in JS is that by sending the full table out (as you'd do with a perl solution), you're outputting a lot more data than is needed.

I use the following javascript to let people select a color in a form text field. The text field lets them type a color if they know it, or they click a button to choose one:

function choosecolor(form, name, title) {"about:blank","colorWindow","width=400 +,height=120,resizable=yes") colorlist = new Array('00','33','66','99','CC','FF'); colorWindow.document.write("<table border=0 cellpadding=0 cell +spacing=0>"); colorWindow.document.write("<tr><td colspan=3 align=center><fo +nt face='arial,helvetica,sans' size=3><b>" + title + "</b></td></tr>" +); colorWindow.document.write(" <tr>"); for (var rcolor in colorlist) { colorWindow.document.write(" <td>"); colorWindow.document.write(" <table border=0 ce +llpadding=0 cellspacing=2>"); for (var gcolor in colorlist) { colorWindow.document.write(" <tr>"); for (var bcolor in colorlist) { colorWindow.document.write(" <t +d bgcolor='#" + colorlist[rcolor] + colorlist[bcolor] + colorlist[gco +lor] + "'><a href=\"javascript:window.opener.document." + form + "." ++ name + ".value='#" + colorlist[rcolor] + colorlist[bcolor] + colorl +ist[gcolor] + "'; self.close()\"><img src="./images/clearpixel.gif' w +idth=8 height=8 border=0></a></td>"); } colorWindow.document.write(" </tr>"); } colorWindow.document.write(" </table>"); colorWindow.document.write(" </td>"); } colorWindow.document.write(" </tr>"); colorWindow.document.write("</table></font><form><input type=b +utton value=' Cancel ' onclick='self.close()'></form></center>");
Which works from a form like this:
<form name=colorpicker> Enter a color:<input name=color type=text><input type=button value="Pi +ck" onclick="choosecolor('colorpicker', 'color', 'Pick a color for no + reason at all')"> </form>
Hope this helps ... please forgive the lack of a perl solution, but note the above reasoning for it.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://188801]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-05-28 01:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found