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.


Views: 39313
Closed Thread
 
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
 
Send a message via AIM to cutterofcloth




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
 
Send a message via AIM to iDeviseFlash




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
 
Send a message via AIM to cutterofcloth




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
 
Send a message via AIM to iDeviseFlash




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




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



Domain name forum recommended by Domaining.com
Powered by: vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO
Don't use this form or this link. If you do, you'll automatically be blocked. nofollow