School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,485 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,781 people online right now. Registration is fast and FREE... Join Now!




Dynamic Hexadecimal Colors not working in IE

 

Dynamic Hexadecimal Colors not working in IE

xheartonfire43x

25 Mar, 2009 - 07:06 AM
Post #1

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 260



Thanked: 2 times
My Contributions
So I am still building a calendar and now I am trying to get categorized appointments. So I have a form where people can say "I want this category to be blue" and so it puts a hexadecimal character into the DB. (AKA blue = 0033FF, Red = CC0000, Orange = FF6600)., Probably is that in IE 8 ( the main browser that this app needs to work on) only shows either red or green. If the color is like orange or yellow it shows red. If it is blue it shows green. When I put the color in as static hexadecimal it works fine. The best part is that when it is green it shows maroon. So none of the colors at all work. I do a cfdump and the right hexadecmial code dumps. It doesn't show though.

CODE

        <cfloop index="x" from="1" to="#days#">
            <!---Create a variable for the current date so that it can be compared to the query--->
            <cfset thisdate = createdate(currentyear,currentmonth,x)>

            <!---If we are on the current day then highlight it in yellow--->
            
             <cfif x is currentday>
                    <td bgcolor="yellow" valign="top">
             <cfelse>
                    <td valign="top">
             </cfif>
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            <!---Actually output the day #--->
                            <cfoutput>#x#</cfoutput>
                        </td>
                    </tr>
                    <!---Query the database and pull anything between the first day of the month and the last day--->
                    <cfquery name="getAppointments" datasource="#CRE_userdatabase#" username="#CRE_username#" password="#CRE_password#">
                        SELECT * FROM calendar WHERE startdate = '#dateformat(thisdate)#' ORDER BY starttime
                    </cfquery>
                    <!---If there are any events on this day then output them.--->
                    <cfif getAppointments.recordcount gt 0>
                        <cfloop query="getAppointments">
                            <cfif isDefined('getAppointments.category')>
                                <cfquery name="getCatColor" datasource="#CRE_userdatabase#" username="#CRE_username#" password="#CRE_password#">
                                    SELECT color FROM calendarcats WHERE catid = <cfqueryparam value="#getAppointments.category#">
                                </cfquery>
                            </cfif>
                            <cfoutput><tr><td width="100%" <cfif isDefined('getAppointments.category')>bgcolor="###getcatcolor.color#"</cfif>><cfdump var="#getcatcolor.color#">#getAppointments.subject#</td></tr></cfoutput>
                        </cfloop>
                    </cfif>
                </table>
             </td>
             <!---Add one to the counter--->
             <cfset counter = counter + 1>
             <!---If the counter hites 8 than the end of the week has been reached the row must end--->
             <cfif counter is 8>
                 </tr>
                    <!---If it isn't the end of the month then set the counter back to 1--->
                    <cfif x lt days>
                         <cfset counter = 1>
                         <cfoutput>
                         <tr>
                         </cfoutput>
                    </cfif>
             </cfif>
        </cfloop>



Any ideas?

This post has been edited by xheartonfire43x: 25 Mar, 2009 - 07:10 AM

User is offlineProfile CardPM
+Quote Post


sansclue

RE: Dynamic Hexadecimal Colors Not Working In IE

25 Mar, 2009 - 07:58 AM
Post #2

D.I.C Regular
***

Joined: 21 Nov, 2007
Posts: 316



Thanked: 28 times
My Contributions
Do a view -> source to see the actual html that is being generated. It must be different than your hard coded value somehow. Because there is no reason a hard coded color:

<td bgColor="#0033FF">....

... should work differently than the same html generated by CF. You might also try using CSS instead of "bgColor". ie Create a class for each color, then use the "class" in your <td> cells instead.


User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Dynamic Hexadecimal Colors Not Working In IE

25 Mar, 2009 - 08:35 AM
Post #3

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 260



Thanked: 2 times
My Contributions
QUOTE(sansclue @ 25 Mar, 2009 - 07:58 AM) *

Do a view -> source to see the actual html that is being generated. It must be different than your hard coded value somehow. Because there is no reason a hard coded color:

<td bgColor="#0033FF">....

... should work differently than the same html generated by CF. You might also try using CSS instead of "bgColor". ie Create a class for each color, then use the "class" in your <td> cells instead.


All the code looks fine except for one irrevelevant part that I fixed. The correct color is there. Like I said before it works fine in FireFox so it has something to do with when the HTML generated by ColdFusion hits IE. Works fine when I do CSS

CODE

<cfoutput><tr><td width="100%"  <cfif isDefined('getcatcolor')>style="background-color:###getcatcolor.color#; "</cfif>>#getAppointments.subject#</td></tr></cfoutput>


That is really weird.

CODE

<table border="1" width="98%" height="100%">
    <tr>
        <th colspan="7">
                <a href="monthview.cfm?datelast={ts '2009-02-01 00:00:00'}" style="text-decoration:none; ">&lt;&lt;</a>
                &nbsp;&nbsp;&nbsp; March 2009 &nbsp;&nbsp;&nbsp;
                <a href="monthview.cfm?datenext={ts '2009-04-01 00:00:00'}" style="text-decoration:none; ">&gt;&gt;</a>
        </th>
    </tr>
    <tr>
            <th width="14%">
                    Sunday
            </th>
            <th width="14%">
                    Monday
            </th>
            <th width="14%">
                    Tuesday
            </th>
            <th width="14%">
                    Wednesday
            </th>
            <th width="14%">
                    Thursday
            </th>
            <th width="14%">
                    Friday
            </th>
            <th width="14%">
                    Saturday
            </th>
    </tr>
    <tr>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            1
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            2
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            3
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            4
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
            
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            
                            5
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            6
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            7
                        </td>
                    </tr>
                </table>
             </td>
                 </tr>
                         <tr>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            8
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            9
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            10
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            11
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            12
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            13
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
            
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            14
                        </td>
                    </tr>
                </table>
             </td>
                 </tr>
                         <tr>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            15
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            16
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            17
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            18
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            19
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            20
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            21
                        </td>
                    </tr>
                </table>
             </td>
                 </tr>
                         <tr>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            
                            22
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            23
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            24
                        </td>
                    </tr>
                            <tr><td width="100%" bgcolor="#9900FF    ">Build CRM</td></tr>
                </table>
             </td>
                    <td bgcolor="yellow" valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            25
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            26
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            27
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            28
                        </td>
                    </tr>
                </table>
             </td>
                 </tr>
                         <tr>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            29
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            30
                        </td>
                    </tr>
                </table>
             </td>
                    <td valign="top">
                 <table width="100%" cellpadding="0" cellspacing="1" border="0">
                    <tr>
                        <td>
                            31
                        </td>
                    </tr>
                </table>
             </td>
             <td colspan="#endPad#">&nbsp;</td></tr>
</table>


This post has been edited by xheartonfire43x: 25 Mar, 2009 - 08:45 AM
User is offlineProfile CardPM
+Quote Post

sansclue

RE: Dynamic Hexadecimal Colors Not Working In IE

25 Mar, 2009 - 10:07 AM
Post #4

D.I.C Regular
***

Joined: 21 Nov, 2007
Posts: 316



Thanked: 28 times
My Contributions
QUOTE(xheartonfire43x @ 25 Mar, 2009 - 08:35 AM) *

<tr><td width="100%" bgcolor="#9900FF(spaces here)">Build CRM</td></tr>


This may sound crazy, but could it be due to trailing spaces at the end of the color value? If you trim the color value does it work?

It doesn't look like the CF code should be adding spaces. Maybe the "Color" value in the database has some extra spaces .. or is being stored in a CHAR field?

This post has been edited by sansclue: 25 Mar, 2009 - 10:07 AM
User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Dynamic Hexadecimal Colors Not Working In IE

26 Mar, 2009 - 07:57 AM
Post #5

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 260



Thanked: 2 times
My Contributions
QUOTE(sansclue @ 25 Mar, 2009 - 10:07 AM) *

This may sound crazy, but could it be due to trailing spaces at the end of the color value? If you trim the color value does it work?

It doesn't look like the CF code should be adding spaces. Maybe the "Color" value in the database has some extra spaces .. or is being stored in a CHAR field?



I should've tried putting a trim function around it but it works when I do CSS which is the better thing to do because the bgcolor attribute is deprecated, so as long as it works the better way then I am not gonna touch it. I will bet though that it is the spaces that did it...although there wasn't a trim function there. Maybe CSS just looked at it differently.
User is offlineProfile CardPM
+Quote Post

sansclue

RE: Dynamic Hexadecimal Colors Not Working In IE

26 Mar, 2009 - 11:12 AM
Post #6

D.I.C Regular
***

Joined: 21 Nov, 2007
Posts: 316



Thanked: 28 times
My Contributions
QUOTE(xheartonfire43x @ 26 Mar, 2009 - 07:57 AM) *

I should've tried putting a trim function around it but it works when I do CSS which is the better thing to do because the bgcolor attribute is deprecated, so as long as it works the better way then I am not gonna touch it. I will bet though that it is the spaces that did it...although there wasn't a trim function there. Maybe CSS just looked at it differently.


Yes, that was deprecated a while ago. Though bgColor has been around for so long, I would be surprised if browsers stopped supporting it any time soon. I would guess an embarrassingly large number of web pages would break overnight ;-)

With the colors I was thinking more along the lines of css classes than in-line styles, but ... if it ain't broke don't fix it!
User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Dynamic Hexadecimal Colors Not Working In IE

27 Mar, 2009 - 06:37 AM
Post #7

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 260



Thanked: 2 times
My Contributions
QUOTE(sansclue @ 26 Mar, 2009 - 11:12 AM) *

QUOTE(xheartonfire43x @ 26 Mar, 2009 - 07:57 AM) *

I should've tried putting a trim function around it but it works when I do CSS which is the better thing to do because the bgcolor attribute is deprecated, so as long as it works the better way then I am not gonna touch it. I will bet though that it is the spaces that did it...although there wasn't a trim function there. Maybe CSS just looked at it differently.


Yes, that was deprecated a while ago. Though bgColor has been around for so long, I would be surprised if browsers stopped supporting it any time soon. I would guess an embarrassingly large number of web pages would break overnight ;-)

With the colors I was thinking more along the lines of css classes than in-line styles, but ... if it ain't broke don't fix it!


Yeah I was about to do classes but I just decided it was just as easy to do inline style. Regardless when this gets made the only thing that needs to get changed is the DB colors.

User is offlineProfile CardPM
+Quote Post

sansclue

RE: Dynamic Hexadecimal Colors Not Working In IE

27 Mar, 2009 - 10:19 AM
Post #8

D.I.C Regular
***

Joined: 21 Nov, 2007
Posts: 316



Thanked: 28 times
My Contributions
QUOTE(xheartonfire43x @ 27 Mar, 2009 - 06:37 AM) *

Yeah I was about to do classes but I just decided it was just as easy to do inline style. Regardless when this gets made the only thing that needs to get changed is the DB colors.


You can easily generate css classes dynamically from a db query, assuming the colors table is normalized. But I do not know if there is a major advantage to doing so here.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:08AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month