Script Categories













Equivalents >>> Rgb To Hex.

Converts the RGB (Red, Green, Blue) value you enter to its appropriate HTML hexademical value. Allows you to use the same color on a web page and in a graphics editor program.

Enter the Red, Green, and Blue colors. (0 to 255)

Red:   
Green: 
Blue:  

 

Hex code:  

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function showRGB(f) {
red = f.red.value;
green = f.green.value;
blue = f.blue.value;
var hexarray= new Array(256);
hexarray[0]="00"; hexarray[1]="01"; hexarray[2]="02";
hexarray[3]="03"; hexarray[4]="04"; hexarray[5]="05";
hexarray[6]="06"; hexarray[7]="07"; hexarray[8]="08";
hexarray[9]="09"; hexarray[10]="0A"; hexarray[11]="0B";
hexarray[12]="0C"; hexarray[13]="0D"; hexarray[14]="0E";
hexarray[15]="0F"; hexarray[16]="10"; hexarray[17]="11";
hexarray[18]="12"; hexarray[19]="13"; hexarray[20]="14";
hexarray[21]="15"; hexarray[22]="16"; hexarray[23]="17";
hexarray[24]="18"; hexarray[25]="19"; hexarray[26]="1A";
hexarray[27]="1B"; hexarray[28]="1C"; hexarray[29]="1D";
hexarray[30]="1E"; hexarray[31]="1F"; hexarray[32]="20";
hexarray[33]="21"; hexarray[34]="22"; hexarray[35]="23";
hexarray[36]="24"; hexarray[37]="25"; hexarray[38]="26";
hexarray[39]="27"; hexarray[40]="28"; hexarray[41]="29";
hexarray[42]="2A"; hexarray[43]="2B"; hexarray[44]="2C";
hexarray[45]="2D"; hexarray[46]="2E"; hexarray[47]="2F";
hexarray[48]="30"; hexarray[49]="31"; hexarray[50]="32";
hexarray[51]="33"; hexarray[52]="34"; hexarray[53]="35";
hexarray[54]="36"; hexarray[55]="37"; hexarray[56]="38";
hexarray[57]="39"; hexarray[58]="3A"; hexarray[59]="3B";
hexarray[60]="3C"; hexarray[61]="3D"; hexarray[62]="3E";
hexarray[63]="3F"; hexarray[64]="40"; hexarray[65]="41";
hexarray[66]="42"; hexarray[67]="43"; hexarray[68]="44";
hexarray[69]="45"; hexarray[70]="46"; hexarray[71]="47";
hexarray[72]="48"; hexarray[73]="49"; hexarray[74]="4A";
hexarray[75]="4B"; hexarray[76]="4C"; hexarray[77]="4D";
hexarray[78]="4E"; hexarray[79]="4F"; hexarray[80]="50";
hexarray[81]="51"; hexarray[82]="52"; hexarray[83]="53";
hexarray[84]="54"; hexarray[85]="55"; hexarray[86]="56";
hexarray[87]="57"; hexarray[88]="58"; hexarray[89]="59";
hexarray[90]="5A"; hexarray[91]="5B"; hexarray[92]="5C";
hexarray[93]="5D"; hexarray[94]="5E"; hexarray[95]="6F";
hexarray[96]="60"; hexarray[97]="61"; hexarray[98]="62";
hexarray[99]="63"; hexarray[100]="64"; hexarray[101]="65";
hexarray[102]="66"; hexarray[103]="67"; hexarray[104]="68";
hexarray[105]="69"; hexarray[106]="6A"; hexarray[107]="6B";
hexarray[108]="6C"; hexarray[109]="6D"; hexarray[110]="6E";
hexarray[111]="6F"; hexarray[112]="70"; hexarray[113]="71";
hexarray[114]="72"; hexarray[115]="73"; hexarray[116]="74";
hexarray[117]="75"; hexarray[118]="76"; hexarray[119]="77";
hexarray[120]="78"; hexarray[121]="79"; hexarray[122]="7A";
hexarray[123]="7B"; hexarray[124]="7C"; hexarray[125]="7D";
hexarray[126]="7E"; hexarray[127]="7F"; hexarray[128]="80";
hexarray[129]="81"; hexarray[130]="82"; hexarray[131]="83";
hexarray[132]="84"; hexarray[133]="85"; hexarray[134]="86";
hexarray[135]="87"; hexarray[136]="88"; hexarray[137]="89";
hexarray[138]="8A"; hexarray[139]="8B"; hexarray[140]="8C";
hexarray[141]="8D"; hexarray[142]="8E"; hexarray[143]="8F";
hexarray[144]="90"; hexarray[145]="91"; hexarray[146]="92";
hexarray[147]="93"; hexarray[148]="94"; hexarray[149]="95";
hexarray[150]="96"; hexarray[151]="97"; hexarray[152]="98";
hexarray[153]="99"; hexarray[154]="9A"; hexarray[155]="9B";
hexarray[156]="9C"; hexarray[157]="9D"; hexarray[158]="9E";
hexarray[159]="9F"; hexarray[160]="A0"; hexarray[161]="A1";
hexarray[162]="A2"; hexarray[163]="A3"; hexarray[164]="A4";
hexarray[165]="A5"; hexarray[166]="A6"; hexarray[167]="A7";
hexarray[168]="A8"; hexarray[169]="A9"; hexarray[170]="AA";
hexarray[171]="AB"; hexarray[172]="AC"; hexarray[173]="AD";
hexarray[174]="AE"; hexarray[175]="AF"; hexarray[176]="B0";
hexarray[177]="B1"; hexarray[178]="B2"; hexarray[179]="B3";
hexarray[180]="B4"; hexarray[181]="B5"; hexarray[182]="B6";
hexarray[183]="B7"; hexarray[184]="B8"; hexarray[185]="B9";
hexarray[186]="BA"; hexarray[187]="BB"; hexarray[188]="BC";
hexarray[189]="BD"; hexarray[190]="BE"; hexarray[191]="BF";
hexarray[192]="C0"; hexarray[193]="C1"; hexarray[194]="C2";
hexarray[195]="C3"; hexarray[196]="C4"; hexarray[197]="C5";
hexarray[198]="C6"; hexarray[199]="C7"; hexarray[200]="C8";
hexarray[201]="C9"; hexarray[202]="CA"; hexarray[203]="CB";
hexarray[204]="CC"; hexarray[205]="CD"; hexarray[206]="CE";
hexarray[207]="CF"; hexarray[208]="D0"; hexarray[209]="D1";
hexarray[210]="D2"; hexarray[211]="D3"; hexarray[212]="D4";
hexarray[213]="D5"; hexarray[214]="D6"; hexarray[215]="D7";
hexarray[216]="D8"; hexarray[217]="D9"; hexarray[218]="DA";
hexarray[219]="DB"; hexarray[220]="DC"; hexarray[221]="DD";
hexarray[222]="DE"; hexarray[223]="DF"; hexarray[224]="E0";
hexarray[225]="E1"; hexarray[226]="E2"; hexarray[227]="E3";
hexarray[228]="E4"; hexarray[229]="E5"; hexarray[230]="E6";
hexarray[231]="E7"; hexarray[232]="E8"; hexarray[233]="E9";
hexarray[234]="EA"; hexarray[235]="EB"; hexarray[236]="EC";
hexarray[237]="ED"; hexarray[238]="EE"; hexarray[239]="EF";
hexarray[240]="F0"; hexarray[241]="F1"; hexarray[242]="F2";
hexarray[243]="F3"; hexarray[244]="F4"; hexarray[245]="F5";
hexarray[246]="F6"; hexarray[247]="F7"; hexarray[248]="F8";
hexarray[249]="F9"; hexarray[250]="FA"; hexarray[251]="FB";
hexarray[252]="FC"; hexarray[253]="FD"; hexarray[254]="FE";
hexarray[255]="FF";
hexcode = "#" + hexarray[red] + hexarray[green] + hexarray[blue];
document.bgColor = f.hexval.value = hexcode;
}
// End -->
</script>
<form name=rgbform>
<pre>
<b>Enter the Red, Green, and Blue colors. (0 to 255)</b>

Red: <input type="text" name="red" size="4">
Green: <input type="text" name="green" size="4">
Blue: <input type="text" name="blue" size="4">

<input type=button value="Show Hex #" onClick="showRGB(this.form)">

Hex code: <input type=text name=hexval size=7>
</pre>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©