NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page javascript: random hex color

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-04-2004, 11:35 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Jul 2004
Location: Clackamas, OR
Posts: 75
cutterofcloth is an unknown quantity at this point
 



javascript: random hex color


I made this last year when I was bored, it is a simple javascript where you press a button and a random hex color shows up in the box, along with its number.

It is here online: http://www.therustybarrel.com/david/...s/randhex.html

But here's the main code:


<script language="Javascript">
<!--
function genHex(){
colors = new Array(14)
colors[0]="0"
colors[1]="1"
colors[2]="2"
colors[3]="3"
colors[4]="4"
colors[5]="5"
colors[5]="6"
colors[6]="7"
colors[7]="8"
colors[8]="9"
colors[9]="a"
colors[10]="b"
colors[11]="c"
colors[12]="d"
colors[13]="e"
colors[14]="f"

digit = new Array(5)
color=""
for (i=0;i<6;i++){
digit[i]=colors[Math.round(Math.random()*14)]
color = color+digit[i]
}
document.getElementById('hexc').style.backgroundCo lor=color
????: NamePros.com http://www.namepros.com/code/37251-javascript-random-hex-color.html
document.getElementById('hexn').innerText="#"+colo r
}
//-->
</script>


<table>
<tr>
<td id="hexc" height="100" width="100">&nbsp;</td><td id="hexn"></td>
</tr>
</table>
<form>
<input type="button" onClick="genHex();"value="Generate Random Color">
</form>

enjoy ^_^
cutterofcloth is offline  
Old 07-10-2004, 12:28 PM   #2 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



nice, lol. Doing fun things like that is wel, fun!
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Old 07-10-2004, 01:06 PM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Jul 2004
Location: Clackamas, OR
Posts: 75
cutterofcloth is an unknown quantity at this point
 



lol, good call
cutterofcloth is offline  
Old 07-10-2004, 01:18 PM   #4 (permalink)
Senior Member
 
iDeviseFlash's Avatar
Join Date: Jun 2004
Posts: 1,030
iDeviseFlash will become famous soon enoughiDeviseFlash will become famous soon enough
 



haha, while we are at it, you got any mroe you wanna share?
__________________
~*~* SIG FOR SALE *~*~
Click here...
iDeviseFlash is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 10:05 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger