Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

setting the results of a query to a variable

Guest
Apr 20, 2009 Apr 20, 2009

Hi all,

     I'm having a problem setting the results of a query to a variable. What I'm trying to do is make an AJAX call to a .cfc file and pass back the results of the function. The main problem is, I'm trying to pass back a block of HTML code ( resulting from a cfquery to a cfoutput ) stored in a variable. My code is something like..

<cffunction name="getText" access="remote" returntype="void">

        <cfquery datasource="#request.dsn#" name="queryTable">
            SELECT  infoA, infoB

            FROM  infoTable

        </cfquery>

       
        <cfset result = '<!--- this is the part I'm stuck on, I want the table to go here. --->'>

              <table>
                  <cfoutput query="tablequery">
                  <tr>
                  <td>#infoA#</td><td>#infoB#</td>
                  </tr>
                  </cfoutput>
              </table>


    <cfwddx action="cfml2js" input="#result#" toplevelvariable="r">

</cffunction>

This is a simplified version of what I want to do, but you get the idea..

Is this even the right way of going about it??  Thanks

TOPICS
Advanced techniques
555
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Apr 20, 2009 Apr 20, 2009

That is what I get for trying the e-mail reply feature!  Aren't you glad I double checked my post.

You could do a bunch of string concatenation here doing stuff like  <cfset result = result & "<td>" & infoA & "</td><td>" & infoB & "</td>">  over and over again.  But really the <cfsaveContent...> tags is so much  easier to use.

<cfsaveContent variable="result">

<table>
<cfoutput query="tablequery">
   <tr>
     <td>#infoA#</td><td>#infoB#</td>
   </tr>
</cfoutput>
</table>

</cfsaveContent>

Translate
Valorous Hero ,
Apr 20, 2009 Apr 20, 2009
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 20, 2009 Apr 20, 2009

That is what I get for trying the e-mail reply feature!  Aren't you glad I double checked my post.

You could do a bunch of string concatenation here doing stuff like  <cfset result = result & "<td>" & infoA & "</td><td>" & infoB & "</td>">  over and over again.  But really the <cfsaveContent...> tags is so much  easier to use.

<cfsaveContent variable="result">

<table>
<cfoutput query="tablequery">
   <tr>
     <td>#infoA#</td><td>#infoB#</td>
   </tr>
</cfoutput>
</table>

</cfsaveContent>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2009 Apr 20, 2009
LATEST

You are the best. I didn't even think of that. Thanks so much for the help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources