Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Highlighting the current day

$
0
0

Hi, happy new year.

I have some code that gives me a calendar on my cfml page.

Is there a way that I can modify this so that the current day has a background color?

Thank you very much.

 

 

 

<code>

 

<cfset thisYear = year(now())>

<cfset thisMonth = month(now())>

 

 

<p><cfoutput>#MonthAsString(thisMonth)# of #thisYear#</cfoutput>

 

 

<cfoutput>

<table border="1" width="100%" height="100%">

   <tr>

   <cfloop index="x" from="1" to="7">

      <th>#dayOfWeekAsString(x)#</th>

   </cfloop>

   </tr>

</cfoutput>

 

 

<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>

 

 

<cfset dow = dayofWeek(firstOfTheMonth)>

<!---This gives us a number between 1 and 7. Our pad will be the day of the week minus 1.--->

 

 

<cfset pad = dow - 1>

<!---Now we need to create the first row of the calendar with empty boxes, if any:--->

 

 

<cfoutput>

<tr>

</cfoutput>

 

 

<cfif pad gt 0>

   <cfoutput><td colspan="#pad#"> </td></cfoutput>

</cfif>

 

 

<cfset days = daysInMonth(now())>

<cfset counter = pad + 1>

<cfloop index="x" from="1" to="#days#">

   <cfoutput>

   <td>#x#</td>

   </cfoutput>

   <cfset counter = counter + 1>

   <cfif counter is 8>

      <cfoutput></tr></cfoutput>

      <cfif x lt days>

         <cfset counter = 1>

         <cfoutput>

         <tr>

         </cfoutput>

      </cfif>

   </cfif>

</cfloop>

 

 

<cfif counter is not 8>

   <cfset endPad = 8 - counter>

   <cfoutput>

   <td colspan="#endPad#"> </td>

   </cfoutput>

</cfif>

 

</code>


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>