Click here to Skip to main content
15,906,467 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: Simple CSS question Pin
MatrixCoder7-May-07 16:08
MatrixCoder7-May-07 16:08 
GeneralRe: Simple CSS question Pin
xxrono7-May-07 16:26
xxrono7-May-07 16:26 
GeneralRe: Simple CSS question Pin
JimmyRopes12-May-07 4:59
professionalJimmyRopes12-May-07 4:59 
AnswerRe: Simple CSS question Pin
Fred_Smith8-May-07 1:40
Fred_Smith8-May-07 1:40 
QuestionVS. NET 2003 - ASPX Vs ASPX.vb question Pin
No-e7-May-07 6:17
No-e7-May-07 6:17 
AnswerRe: VS. NET 2003 - ASPX Vs ASPX.vb question Pin
RichardGrimmer8-May-07 5:52
RichardGrimmer8-May-07 5:52 
GeneralRe: VS. NET 2003 - ASPX Vs ASPX.vb question Pin
No-e8-May-07 5:55
No-e8-May-07 5:55 
QuestionVBScript questions [SOLVED] Pin
#realJSOP7-May-07 4:23
professional#realJSOP7-May-07 4:23 
1) Is there a way to debug VBScript in a web page?

2) I have a string that represents a color, let's say "#FFFF00". How do I convert that into the individual component colors, like FF, FF, and 00? Here's what I've tried so far:

'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
function GetColorValue(sColor, nShade)
    Replace sColor, "#", ""
    Dim nVal: nVal = 0
    select case nShade
        case 0 nVal = CLng("&H" & (Mid(1, 2)))    ' red
        case 1 nVal = CLng("&H" & (Mid(3, 2)))    ' green
        case 2 nVal = CLng("&H" & (Mid(5, 2)))    ' blue
    end select
    GetColorValue = nVal
end function


2a) Would I be better off usng javascript for this function?

2b) Can I even return a value from a javascript function to vbscript code?




-- modified at 11:57 Monday 7th May, 2007

Here's what I ended up with:

'-------------------------------------------------------------------------------
' Extracts the color value from the string that represents the backgorund color.
' It's assumed that the color will ALWAYS be in the standard hex notation of    
' #RRGGBB.  jms - 07May2007                                                     
'-------------------------------------------------------------------------------
function GetColorValue(sColor, nShade)
    Dim nVal: nVal = 0
    select case nShade
        case 0 nVal = CLng("&H" & (Mid(sColor, 2, 2)))  ' red
        case 1 nVal = CLng("&H" & (Mid(sColor, 4, 2)))  ' green
        case 2 nVal = CLng("&H" & (Mid(sColor, 6, 2)))  ' blue
        case else nVal = 255
    end select
    GetColorValue = nVal
end function

'-------------------------------------------------------------------------------
' Determines the best choice of text color based on the background color. The   
' two possible resulting values are black text or white text.  jms - 07MAY2007  
'-------------------------------------------------------------------------------
function BestFontColor(sBkColor)
    if sBkColor(1) <> "#" OR Len(sBkColor) < 7 then
        BestFontColor = "#000000"
        exit function
    end if
    Dim nRed:   nRed   = GetColorValue(sBkColor, 0)
    Dim nGreen: nGreen = GetColorValue(sBkColor, 1)
    Dim nBlue:  nBlue  = GetColorValue(sBkColor, 2)
    
    Dim nThreshold: nThreshold = 105
    Dim bgDelta: bgDelta = int((nRed * 0.299) + (nGreen * 0.587) + (nBlue * 0.114))
    if 255 - bgDelta < nThreshold then
        BestFontColor = "#000000"
    else
        BestFontColor = "#FFFFFF"
    end if
end function


I suppose I could extend the validity checking on the specified background color, but frankly, I'm kinda pressed for time.



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


QuestionPASSING VALUE FROM ASPX TO ANOTHER ASPX Pin
hifiger20047-May-07 1:57
hifiger20047-May-07 1:57 
AnswerRe: PASSING VALUE FROM ASPX TO ANOTHER ASPX Pin
Rahul Babu7-May-07 2:28
Rahul Babu7-May-07 2:28 
AnswerRe: PASSING VALUE FROM ASPX TO ANOTHER ASPX Pin
Elina Blank7-May-07 4:46
sitebuilderElina Blank7-May-07 4:46 
GeneralRe: PASSING VALUE FROM ASPX TO ANOTHER ASPX Pin
hifiger20047-May-07 5:06
hifiger20047-May-07 5:06 
QuestionRedirect from another page Pin
Rahul Babu7-May-07 0:50
Rahul Babu7-May-07 0:50 
AnswerRe: Redirect from another page Pin
Dev_Aditya7-May-07 1:29
Dev_Aditya7-May-07 1:29 
GeneralRe: Redirect from another page Pin
Rahul Babu7-May-07 1:43
Rahul Babu7-May-07 1:43 
GeneralRe: Redirect from another page Pin
Bradml7-May-07 2:24
Bradml7-May-07 2:24 
Questionwebsite margin to fit all screen resolution Pin
dheema6-May-07 21:56
dheema6-May-07 21:56 
AnswerRe: website margin to fit all screen resolution Pin
steffw7-May-07 23:17
steffw7-May-07 23:17 
Generalhere the code Pin
dheema8-May-07 19:18
dheema8-May-07 19:18 
QuestionClear Browser's Cache after hitting Logout Button? Pin
md Nazeem6-May-07 21:40
md Nazeem6-May-07 21:40 
AnswerRe: Clear Browser's Cache after hitting Logout Button? Pin
Sherin Iranimose7-May-07 0:12
Sherin Iranimose7-May-07 0:12 
QuestiongetElementById - How many people still code for browsers that don't upport this? Pin
MartinSmith6-May-07 7:02
MartinSmith6-May-07 7:02 
AnswerRe: getElementById - How many people still code for browsers that don't upport this? Pin
Fred_Smith6-May-07 8:05
Fred_Smith6-May-07 8:05 
GeneralRe: getElementById - How many people still code for browsers that don't upport this? Pin
Guffa6-May-07 11:24
Guffa6-May-07 11:24 
GeneralRe: getElementById - How many people still code for browsers that don't upport this? Pin
Fred_Smith6-May-07 11:37
Fred_Smith6-May-07 11:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.