NamePros.com  


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.

0 members in live chat ~

Views: 38694
Closed Thread
 
LinkBack Thread Tools
Old 07-04-2004, 10:35 AM THREAD STARTER               #1 (permalink)
NamePros Member
cutterofcloth's Avatar
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
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, 11:28 AM   #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, 12:06 PM THREAD STARTER               #3 (permalink)
NamePros Member
cutterofcloth's Avatar
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, 12: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


LinkBacks (?)
LinkBack to this Thread: http://www.namepros.com/code/37251-javascript-random-hex-color.html
Posted By For Type Date
Javascript random kleuren, en image + klein vraagje - HTML-site forum This thread Refback 11-02-2011 01:55 AM
javascript random color - Google Search This thread Refback 02-28-2011 01:13 AM
Javascript random kleuren, en image + klein vraagje - HTML-site forum This thread Refback 06-30-2010 02:42 AM
javascript hex color This thread Refback 05-03-2009 10:59 AM

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




All times are GMT -7. The time now is 10:37 PM.


Powered by: vBulletin® Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0
Ad Management plugin by RedTyger