<TABLE cellSpacing=1 cellPadding=3 width=350 align=center bgColor=#dddddd
border=0>
<TBODY>
<TR bgColor=#ffffff>
<TD align=middle width="10%"><SELECT οnchange=selectchg(this.value)
name=select1> <OPTION value=1 selected>红</OPTION> <OPTION
value=2>绿</OPTION> <OPTION value=3>蓝</OPTION> <OPTION
value=4>灰</OPTION></SELECT> </TD>
<TD align=middle width="90%">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=right><INPUT class=memo size=10 name=text1> <INPUT class=button οnclick=choosecolor() type=button value=">>" name=Button2>
</TD>
<TD align=right width="3%"> </TD>
<TD width="30%">
<TABLE class=cursorcross height=20 cellSpacing=1 cellPadding=0
width=40 border=0>
<TBODY>
<TR>
<TD id=customcolor οnmοuseοver=showcolor(this)
bgColor=#ffffff> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR bgColor=#ffffff>
<TD align=middle width="10%">
<TABLE class=cursorhand id=tableleft cellSpacing=1 cellPadding=0
border=0><SCRIPT language=VBScript>
function hexit(which)
hexit=hex(which)
end function
</script>
<SCRIPT language=JavaScript>
for(i=0;i<=15;++i)
{document.write('<tr><td align="center">'+ hexit(0+i*17) +'</td><td id="tdleft' + i +'" bgcolor="rgb('+ (0+i*17) + ',0,0)" width="15" height="15" οnclick="changeright(this.num)" οnmοuseοver="showcolor(this)"></td></tr>')
document.all['tdleft' + i].num=i
}
</SCRIPT>
<TBODY></TBODY></TABLE></TD>
<TD align=middle width="90%">
<TABLE class=cursorcross id=tableleft cellSpacing=1 cellPadding=0
border=0>
<SCRIPT language=JavaScript>
document.write('<tr><td></td>')
for(i=0;i<=15;++i)
{document.write('<td align="center">'+ hexit(0+i*17) +'</td>')}
document.write('</tr>')
for(i=0;i<=15;++i)
{document.write('<tr>')
document.write('<td align="center">'+ hexit(0+i*17) +'</td>')
for(j=0;j<=15;++j)
{document.write('<td id="tdrightr' + i + 'c' + j +'" bgcolor="rgb(0,'+ (0+i*17) + ',' + (0+j*17) + ')" width="15" height="15" οnmοuseοver="showcolor(this)" οnclick="clickright(this)"></td>')}
document.write('</tr>')
}
</SCRIPT>
<TBODY></TBODY></TABLE></TD></TR>
<TR bgColor=#ffffff>
<TD colSpan=2
height=20>·可选16*16*16种颜色。<BR>·单击左边的颜色会得到更多的颜色。<BR>·单击右边的颜色会固定选取的颜色。
<BR>·输入框可以自定义颜色。</TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript>
function selectchg(which)
{switch(which)
{case '1' :leftR();break;
case '2' :leftG();break;
case '3' :leftB();break;
case '4' :leftA();break;
}
}
function leftR()
{for(i=0;i<=15;++i)
{document.all['tdleft'+i].bgColor='rgb('+ (0+i*17) + ',0,0)'}
rightR(0)
}
function leftG()
{for(i=0;i<=15;++i)
{document.all['tdleft'+i].bgColor='rgb(0,'+ (0+i*17) + ',0)'}
rightG(0)
}
function leftB()
{for(i=0;i<=15;++i)
{document.all['tdleft'+i].bgColor='rgb(0,0,'+ (0+i*17) + ')'}
rightB(0)
}
function leftA()
{for(i=0;i<=15;++i)
{document.all['tdleft'+i].bgColor='rgb('+ (0+i*17) + ','+ (0+i*17) + ','+ (0+i*17) + ')'}
rightA()
}
function rightR(which)
{for(i=0;i<=15;++i)
{for(j=0;j<=15;++j)
{document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+which*17) + ',' + (0+i*17) + ','+ (0+j*17) + ')'}
}
}
function rightG(which)
{for(i=0;i<=15;++i)
{for(j=0;j<=15;++j)
{document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*17) + ',' + (0+which*17) + ',' + (0+j*17) + ')'}
}
}
function rightB(which)
{for(i=0;i<=15;++i)
{for(j=0;j<=15;++j)
{document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*17) + ','+ (0+j*17)+ ',' + (0+which*17) + ')'}
}
}
function rightA()
{for(i=0;i<=15;++i)
{for(j=0;j<=15;++j)
{document.all['tdrightr' + i + 'c' + j].bgColor='rgb(' + (0+i*16+j) + ','+ (0+i*16+j)+ ',' + (0+i*16+j) + ')'}
}
}
var rightclicked=false
function clickright(which)
{if(rightclicked){rightclicked=false;showcolor(which)}else{rightclicked=true}
}
function changeright(which)
{switch(select1.value)
{case '1' :rightR(which);break;
case '2' :rightG(which);break;
case '3' :rightB(which);break;
}
}
function showcolor(which)
{if(rightclicked)return;
text1.value=which.bgColor
choosecolor()
}
function choosecolor()
{customcolor.bgColor=text1.value
}
</SCRIPT>
转载于:https://www.cnblogs.com/robinlin/archive/2008/07/21/1247540.html