Use the JS code to write a color picker used on a Web page, that is, choose the color, with the mouse click any color block, will pop up the color value, when you want to use a color and do not know the color value of the time, with this small special effects can tell you how much color value, more convenient.
<ptml> <pead> <title> Color picker </title> <meta http-equiv= "Content-type" content= text/html; charset=gb2312 "> <style type=" text/css "> <!--. Style1 {color: #FFFFFF}--> </style> </HEAD&G T <body > <span class= "style1" ></span> <table border= "0" cellspacing= "1" cellpadding= "3" width= "350 "Align= Center" bgcolor= "#dddddd" > <tr bgcolor= "#FFFFFF" > <td width= "10%" align= "center" > <select Name= "Select1" onchange= "Selectmenu (this.value)" > <option value= "1" selected> Red </option> <option Value= "2" > Green </option> <option value= "3" > Blue </option> <option value= "4" > Ash </option> </select> </td> <td width= "90%" align= "center" > <table width= "100%" border= "0" cellspacing= "0" ce llpadding= "0" > <tr> <td align= "center" > with the mouse click on the color block below, will eject the color value </td> </tr> </table> < /td> </tr> <tr bgcolor= "#FFFFFF "> <td width=" 10% "align=" center "> <table id=" table1 "border=" 0 "cellspacing=" 1 "cellpadding=" 0 "& Gt <script language= "JavaScript" > for (i=0;i<=15;++i) {document.write (' <tr><td align= ' center ' > ' + Ishex (i*17) + ' </td><td id= ' ' + i + ' "bgcolor=" rgb (' + (i*17) + ', 0,0) "width=" "height=" "onclick=" Changeri Ght (this.num) "></td></tr>") document.all[' Ltd ' + i].num=i} function Ishex (which) {return which.to String (16); } </script> </table></td> <td width= "90%" align= "center" > <table id= "table2" border= "0" ce llspacing= "1" cellpadding= "0" > <script language= "JavaScript" > document.write (' <tr><td></td > ') for (i=0;i<=15;++i) {document.write (' <td align= ' center ' > ' +ishex ' (i*17) + ' </td> '); } document.write (' </tr> ') for (i=0;i<=15;++i) {document.write (' <tr> ') document.write (' <td align= ' C Enter > ' +ishex (i*17) + ' </td> ') for (j=0;j<=15;++j) {document.write (' <td id= "Rtd ' +i+ ' and ' +j+ '" bgcolor= "RGB (0, ' + (i*17) + ', ' + (j*17) + ')" width= " "Height=" "onclick=" clickright (This) "></td>"); } document.write (' </tr> ')} </script> </table> </td> </tr> </table> <SCRI PT language= "JavaScript" > Function Selectmenu (which) {switch (which) {case ' 1 ': Leftr (); Case ' 2 ': LEFTG (); Case ' 3 ': LeftB (); Case ' 4 ': Lefta (); } function Leftr () {for (i=0;i<=15;++i) {document.all[' +i].bgcolor= ' rgb (' + (i*17) + ', 0,0) '; } rightr (0)} function Leftg () {for (i=0;i<=15;++i) {document.all[' Ltd ' +i].bgcolor= ' rgb (0, ' + (i*17) + ', 0) ' ; RIGHTG (0)} function LeftB () {for (i=0;i<=15;++i) {document.all[' Ltd ' +i].bgcolor= ' rgb (0,0, ' + (i*17) + ') '; } RIGHTB (0)} function Lefta () {for (i=0;i<=15;++i) {document.all[' Ltd ' +i].bgcolor= ' rgb (' + (i*17) + ', ' + (i*17 )+', ' + (i*17) + ') '; } righta ()} function rightr (which) {for (i=0;i<=15;++i) {for (j=0;j<=15;++j) {document.all[' Rtd ' +i+ ' and ' +j].bgcolor= ' rgb (' + (which*17) + ', ' + (i*17) + ', ' + (j*17) + ') '; }} function Rightg (which) {for (i=0;i<=15;++i) {for (j=0;j<=15;++j) {document.all[' Rtd ' +i+ ' and ' +j]. Bgcolor= ' rgb (' + (i*17) + ', ' + (which*17) + ', ' + (j*17) + ') '; }} function RightB (which) {for (i=0;i<=15;++i) {for (j=0;j<=15;++j) {document.all[' Rtd ' + i+ ' and ' +j] . bgcolor= ' rgb (' + (i*17) + ', ' + (j*17) + ', ' + (which*17) + ') '; }} function Righta () {for (i=0;i<=15;++i) {for (j=0;j<=15;++j) {document.all[' Rtd ' +i+ ' and ' +j].bgcol Or= ' rgb (' + (i*16+j) + ', ' + (i*16+j) + ', ' + (i*16+j) + ') '; }} function Clickright (which) {alert (Which.bgcolor)} function Changeright (which) {switch (select1.value) { Case ' 1 ': rightr (which); Case ' 2 ': RIGHTG (which); Case ' 3 ': RIGHTB (which); }} </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]