[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming > CODE

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.


Closed Thread
 
LinkBack Thread Tools
Old 07-04-2004, 10:35 AM   #1 (permalink)
NamePros Member
 
Join Date: Jul 2004
Location: Clackamas, OR
Posts: 76
342.00 NP$ (Donate)

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,039
237.00 NP$ (Donate)

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   #3 (permalink)
NamePros Member
 
Join Date: Jul 2004
Location: Clackamas, OR
Posts: 76
342.00 NP$ (Donate)

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,039
237.00 NP$ (Donate)

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

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


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85