Skip to main content
Participating Frequently
May 1, 2009
Answered

formatting highlighter search results

  • May 1, 2009
  • 1 reply
  • 527 views

I've created a search functionality on my site and what it does now is highlights the words that the person has searched for. i followed the following example:http://forums.adobe.com/message/735391#735391

The problem is that it just list everything out. I want to be able to put things in a table. Here's the code:

<head>

<style type="text/css">.highlight{background-color:yellow;}</style>

</head>

<cfloop query="query1">

<cfoutput>

<CFSET TheOutput = "#Title# / #Description# / #Bug_WorkAround#">

#ReplaceNoCase("#TheOutput#","#form.keyword#","<span class=highlight>#form.keyword#</span>","ALL")#<br>

</cfoutput>
</cfloop>
Is there anyway to let the results display highlighted and in a table?
thanks,

    This topic has been closed for replies.
    Correct answer insuractive

    Once you get the data back from your search query recordset, you have to format the text using HTML in the way you want it to appear.  In the example you gave, the text is formatted:

    Title / Description / Workaround

    You probably want to format the data using something like this:

    <cfsavecontent variable="TheOutput">

    <table>

    <tr>

    <td>Title</td>

    <td>Description</td>

    <td>Workaround</td>

    </tr>

    <cfoutput query="qMySearchQuery">

    <tr>

    <td>#title#</td>

    <td>#description#</td>

    <td>#bugworkaround#</td>

    </tr>

    </cfoutput>

    </table>

    </cfsavecontent>

    <cfoutput>

    #ReplaceNoCase("#TheOutput#","#form.keyword#","<span class=highlight>#form.keyword#</span>","ALL")#<

    </cfoutput>

    1 reply

    insuractiveCorrect answer
    Inspiring
    May 1, 2009

    Once you get the data back from your search query recordset, you have to format the text using HTML in the way you want it to appear.  In the example you gave, the text is formatted:

    Title / Description / Workaround

    You probably want to format the data using something like this:

    <cfsavecontent variable="TheOutput">

    <table>

    <tr>

    <td>Title</td>

    <td>Description</td>

    <td>Workaround</td>

    </tr>

    <cfoutput query="qMySearchQuery">

    <tr>

    <td>#title#</td>

    <td>#description#</td>

    <td>#bugworkaround#</td>

    </tr>

    </cfoutput>

    </table>

    </cfsavecontent>

    <cfoutput>

    #ReplaceNoCase("#TheOutput#","#form.keyword#","<span class=highlight>#form.keyword#</span>","ALL")#<

    </cfoutput>

    eynar23Author
    Participating Frequently
    May 4, 2009

    Thanks insuractive!!! The <cfsavecontent> helped me out immensly!