HTML color Picker (JS color picker effect) _javascript tips

Source: Internet
Author: User
File Name:colorpicker.html
Requirement:internet Explorer or Mozilla
Author:jean-luc Antoine
submitted:26/03/2005
category:4k

Copy Code code as follows:

<form name= "Recherche" method= "POST" action= "yourpage.html" >
<input type=hidden name= "RGB" value= "123" >
<table style= "Background-color: #f6f6f6; border:1px dotted #666;p adding:5px;margin:0px auto;" >
<tr><td Align=right>couleur:<br><small>cliquez pour lister les<br>oeuvres les plus Proches<br>de la couleur sélectionnée</small></td>
&LT;TD style= "border:1px outset #CCF Background-color: #ffe; width=172" >
<div id=temoin style= ' float:right;width:40px;height:128px; ' > </div>

<script language= "Javascript" type= "Text/javascript" >
<!--
var total=1657;var x=y=j=rg=b=0;
var ar=new array (total), var ag=new array (total), var ab=new array (total);
for (Var i=0;i<256;i++) {
ar[i+510]=ar[i+765]=ag[i+1020]=ag[i+5*255]=ab[i]=ab[i+255]=0;
Ar[510-i]=ar[i+1020]=ag[i]=ag[1020-i]=ab[i+510]=ab[1530-i]=i;
ar[i]=ar[1530-i]=ag[i+255]=ag[i+510]=ab[i+765]=ab[i+1020]=255;
if (i<255) {ar[i/2+1530]=127;ag[i/2+1530]=127;ab[i/2+1530]=127;}
}
function P () {var Jla=document.getelementbyid (' choix '); jla.innerhtml=artabus;jla.style.backgroundcolor=artabus; Document.forms[' Recherche '].rgb.value=artabus}
var hexbase=new Array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
var i=0;var jl=new Array ();
for (x=0;x<16;x++) for (y=0;y<16;y++) jl[i++]=hexbase[x]+hexbase[y];
document.write (' < ' + ' table border= "0" cellspacing= "0" cellpadding= "0" onmouseover= "t (event)" onclick= "P ()" > ");
var h=w=63;
for (y=0; y<=h; y++) {
S= ' < ' + ' tr height=2> '; J=math.round (y* (510/(h+1))-255)
for (x=0; x<=w; X + +) {
I=math.round (x* (total/w))
R=ar[i]-j;if (r<0) r=0;if (r>255| | isNaN (R)) r=255
G=ag[i]-j;if (g<0) g=0;if (g>255| | isNaN (G)) g=255
B=ab[i]-j;if (b<0) b=0;if (b>255| | isNaN (B)) b=255
S=s+ ' < ' + ' TD width=2 Bgcolor=# ' +jl[r]+jl[g]+jl[b]+ ' >< ' + '/td> '
}
document.write (s+ ' < ' + '/tr> ')
}
document.write (' < ' + '/table> ');
var Ns6=document.getelementbyid&&!document.all
var Ie=document.all
var artabus= '
function T (e) {
Source=ie?event.srcelement:e.target
if (source.tagname== "TABLE") return
while (source.tagname!= "TD" && source.tagname!= "HTML") source=ns6?source.parentnode:source.parentelement
document.getElementById (' Temoin '). Style.backgroundcolor=artabus=source.bgcolor
}
-->
</script>
<div Id=choix style= ' height:24px; ' onclick= "document.forms[' recherche '].rgb.value= '; this.style.backgroundcolor= '" "> </div><td>< /tr>
&LT;TR&GT;&LT;TD colspan=2 align=center><input type=submit></td></tr>
</table>
</form>


Source: http://www.interclasse.com/scripts/colorpicker.php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.