»
AnglaisFran�aisVietnamien

Imprimer - HEX-RGB Code Convert - JavaScriptBank.com

Version compl�te: jsB@nk » Utilitaire » HEX-RGB Code Convert
URL: https://www.javascriptbank.com/hex-rgb-code-convert.html

HEX-RGB Code Convert © JavaScriptBank.comUn simple outil Pour convertir un code de couleur à partir de code HEX DEC co code et, DEX à code HEX.

Version compl�te: jsB@nk » Utilitaire » HEX-RGB Code Convert
URL: https://www.javascriptbank.com/hex-rgb-code-convert.html



JavaScript
<SCRIPT language=JavaScript><!-- Hide script from Non-JavaScript Browsersfunction GiveDec(Hex){   if(Hex == "A")      Value = 10;   else   if(Hex == "B")      Value = 11;   else   if(Hex == "C")      Value = 12;   else   if(Hex == "D")      Value = 13;   else   if(Hex == "E")      Value = 14;   else   if(Hex == "F")      Value = 15;   else      Value = eval(Hex);   return Value;}function GiveHex(Dec){   if(Dec == 10)      Value = "A";   else   if(Dec == 11)      Value = "B";   else   if(Dec == 12)      Value = "C";   else   if(Dec == 13)      Value = "D";   else   if(Dec == 14)      Value = "E";   else   if(Dec == 15)      Value = "F";   else      Value = "" + Dec;   return Value;}function HexToDec(){   Input = window.document.forms['ColorForm'].elements['HexInput'].value;   Input = Input.toUpperCase();   a = GiveDec(Input.substring(0, 1));   b = GiveDec(Input.substring(1, 2));   c = GiveDec(Input.substring(2, 3));   d = GiveDec(Input.substring(3, 4));   e = GiveDec(Input.substring(4, 5));   f = GiveDec(Input.substring(5, 6));   x = (a * 16) + b;   y = (c * 16) + d;   z = (e * 16) + f;   window.document.forms['ColorForm'].elements['RedOutput'].value = x;   window.document.forms['ColorForm'].elements['GreenOutput'].value = y;   window.document.forms['ColorForm'].elements['BlueOutput'].value = z;   window.document.bgColor = Input;}function DecToHex(){   Red = window.document.forms['ColorForm'].elements['RedInput'].value;   Green = window.document.forms['ColorForm'].elements['GreenInput'].value;   Blue = window.document.forms['ColorForm'].elements['BlueInput'].value;   a = GiveHex(Math.floor(Red / 16));   b = GiveHex(Red % 16);   c = GiveHex(Math.floor(Green / 16));   d = GiveHex(Green % 16);   e = GiveHex(Math.floor(Blue / 16));   f = GiveHex(Blue % 16);   z = a + b + c + d + e + f;   window.document.forms['ColorForm'].elements['HexOutput'].value = z;   window.document.bgColor = z;}// --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<TABLE width="90%">  <FORM name=ColorForm>  <TBODY>  <TR>    <TH colSpan=3>Hex Code     <TH colSpan=3>    <TH>Red     <TH>Green     <TH>Blue   <TR>    <TD colSpan=3><INPUT name=HexInput size=36>     <TD colSpan=3><INPUT onclick=HexToDec() type=button value="Hex -> Dec">     <TD><INPUT name=RedOutput size=10>     <TD><INPUT name=GreenOutput size=10>     <TD><INPUT name=BlueOutput size=10>   <TR>    <TD colSpan=9>      <HR>  <TR>    <TH>Red     <TH>Green     <TH>Blue     <TH colSpan=3>    <TH colSpan=3>Hex Code   <TR>    <TD><INPUT name=RedInput size=10>     <TD><INPUT name=GreenInput size=10>     <TD><INPUT name=BlueInput size=10>     <TD colSpan=3><INPUT onclick=DecToHex() type=button value="Dec -> Hex">     <TD colSpan=3><INPUT name=HexOutput size=36></TD></FORM></TR></TBODY></TABLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->