PDA

View Full Version : [ASP] Random Colors



amitgeorge
January 25th, 2005, 11:51 AM
Does anybody have the function to randomly generate HTML Color codes using VBScript....

I mean totally random using complete range and not just a few selected colors randomly picked

SniperFire
January 31st, 2005, 09:48 PM
Here ya go...

Working sample at http://www.sniperfiredesigns.com/test/rndcolor.asp



<html>
<head>
</head>
<body>
<%
Dim min, max, r, g, b
min = 0
max = 255
RANDOMIZE()
r = Int(((max - min + 1) * Rnd) + min)
g = Int(((max - min + 1) * Rnd) + min)
b = Int(((max - min + 1) * Rnd) + min)
%>
<table width="20%">
<%= "<tr bgcolor='rgb(" & r & "," & g & "," & b & ")'>" %>
<td>&nbsp</td>
</tr>
<tr>
<td><%= "rgb(" & r & "," & g & "," & b & ")" %></td>
</tr>
</table>
</body>
</html>

amitgeorge
February 2nd, 2005, 01:43 AM
fanatastic !!!