<head> <STYLE type=text/css>TD { FONT: bold 16pt arial; TEXT-ALIGN: right } INPUT { BORDER-RIGHT: #ffcc11 1px solid; BORDER-TOP: #ffcc11 1px solid; BORDER-LEFT: #ffcc11 1px solid; BORDER-BOTTOM: #ffcc11 1px solid; BACKGROUND-COLOR: #d3d3e3 } </STYLE> <SCRIPT language=javascript> function inverse(theString) { if(theString.length<6||theString.length>6){ window.alert('You Must Enter a six digit color code') document.rin.reset(); return false; } a=theString.slice(0,2); b=theString.slice(2,4); c=theString.slice(4,6); a1=16*giveHex(a.slice(0,1)); a2=giveHex(a.slice(1,2)); a=a1+a2; b1=16*giveHex(b.slice(0,1)); b2=giveHex(b.slice(1,2)); b=b1+b2; c1=16*giveHex(c.slice(0,1)); c2=giveHex(c.slice(1,2)); c=c1+c2; newColor=DecToHex(255-a)+""+DecToHex(255-b)+""+DecToHex(255-c) alert("You Entered "+theString+" and \nYour inversed Color is \n"+newColor); myText="<table cellspacing='4' bgColor='#efefef' border='0' width='50%'><tr><td bgcolor='#" +""+newColor+"'><font color='#"+theString+"' size=2>Background='#"+newColor+"'<" +"\/font><\/td><td bgColor='#"+newColor+"'><font color='#"+theString+"' face=arial" +">Snippet1<\/font><\/td><\/tr><tr><td bgcolor='#"+theString+"'><font color='#" +""+newColor+"' size=2>Background='#"+theString+"'</font><\/td><td bgColor=" +"'#"+theString+"'><font color='#"+newColor+"'>Snippet2<\/font><\/td><\/tr><\/table>" stat.innerHTML=myText } var hexbase="0123456789ABCDEF"; function DecToHex(number) { return hexbase.charAt((number>> 4)& 0xf)+ hexbase.charAt(number& 0xf); } function giveHex(s){ s=s.toUpperCase(); return parseInt(s,16); } </SCRIPT> </head> <body> <FORM name=rin> <div align="center"> <INPUT name=Luc> <BR> <BR> <INPUT onclick=inverse(this.form.Luc.value) type=button value="Inverse Color"> <INPUT type=reset value=Reset> </div> </FORM> <DIV id=stat></DIV> |