Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re: CGI Colour Palette (Javascript Solution) by BigLug
in thread CGI Colour Palette by sabkat

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-06-22 15:38 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.