Reputation: 195
I have written the following query which functions exactly as I have planned:
<cfquery name="myquery" datasource="abc">
SELECT DISTINCT Right((Format([vDatum],"yyyy")),2) AS DDate
FROM tVCal RIGHT JOIN tVEvents ON tVCal.VItem = tVEvents.EvDate
</cfquery>
Every time this query is run, it outputs a series of two digit year numbers corresponding to years between 1940 and 2039, for which data is available in the database, for example: 00,04,15,28,42,56,58,75,89
Then I have a non-varying list of all year numbers from (19)40 to (20)39 arranged in tabular form, with the first decade looking like this:
<tr><td>40</td><td>41</td><td>42</td><td>43</td><td>44</td><td>45</td><td>46</td><td>47</td><td>48</td><td>49</td>
</tr>
Every time this table is displayed and the document is ready, I need a CF or jQuery function which will format all of the year numbers red which were also contained in the output from the original query.
Ten years ago I might have been able to write this myself, but I will be 80 this year and my head swims whenever I try something new. And if I am in the wrong place here, I would be grateful for a hint on where to go. Frank
Upvotes: 0
Views: 75
Reputation: 20804
You could try something like this:
<cfoutput>
<table>
<tr>
<cfloop list = "#YourListOfNumbers#" index = "number">
<cfset ThisColour = ListFind(ValueList(myquery,DDate), number) ? "red" : "black">
<td style = "Color:#ThisColour#">#number#</td>
</cfloop>
</tr>
</table>
</cfoutput>
You'll need to put in some extra work to get more than one row, but that's not part of the question.
A sample of this logic is available here ==> https://trycf.com/gist/dcedc5c1264a4ce18a91ce496a8c0405/lucee5?theme=monokai
Upvotes: 2