Padding Padding
Janet
Systems
 Register  Login 
Telephone  01628 566 178
Website Design, Hosting and Software Services
  Search 
Padding
corner Padding corner
Padding Padding
corner Padding corner
 ASP Articles

In this article I shall be presenting a method of changing the RGB colours used in HTML. The examples presented in this article related to a requirement to be able to adjust the colour to be illustrated in a <td>, to show a series of stripes getting either lighter or darker.

The first function shown is used to darken the colour. For a given colour and modifier value it will return a darker colour.

<%
function colourDarker(myColour, modifier)
    thisColour=""
    item1=""
    item2=""
    item3=""
    for i = 1 to 6 step 2
        item1=mid(replace(myColour, "#", ""), i, 2)
        item2=mid(modifier, i, 2)
        item1 = CInt("&h"&item1)
        item2 = CInt("&h"&item2)
        item3=(item1-item2)
        if item3<0 then
           
item3=0
        end if
        item3=CSTR(HEX(item3))
        if Len(item3)=1 then item3="0"+item3
        thisColour=thisColour+CStr(item3)
    next
    colourDarker=replace(thisColour, "&H", "")
end function
%>

and finally a short piece of HTML to product some stripes:

 

<table width="100">
<%
    For i = 2 to 8 step
2
    showColour=colourDarker("eeeeee",
cStr
(i & "0" & i & "0" & i & "0"))
%>
<tr
>
<
td width="100" bgcolor="<%=showColour%>">&nbsp;</td
>
</
tr
>
<%next 'i%>
</table>

 

 
 
 
 


This article viewed: 936 times Back

Copyright © 2004-2007 Janet Systems Ltd.

 Print   

DotNetNuke Website design and hosting from £15.00 per month. More...

Looking for a website design company in the Thames Valley, call us on 01628 566178

DotNetNuke Modules
DotNetNuke Modules availalble from Janet Systems

DotNetNuke Skins
DotNetNukeSkins.gif

from Janet Systems

Padding
Copyright 2002-2008 Janet Systems Ltd.   Terms Of Use  Privacy Statement Tuesday, May 13, 2008