-1

Why Won't this work?

$("#selection").change(function () {
   description = $("#selection").val();
   console.log(description);

   <cfquery datasource="#Application.cartdsn#" name="descriptions">
     SELECT d.description FROM descriptionmap d, invoice i
     WHERE
                     i.description=
                        <cfqueryparam value="#description#" cfsqltype="cf_sql_integer" maxlength="20">
   </cfquery> 


      })

I've tested it outside of the jquery and it works fine. Is it not possible to embed a cfquery in jquery? If it is impossible, how would I go about performing this?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Jon Sandness
  • 139
  • 1
  • 1
  • 13
  • Even if it was somehow possible to evaluate server-side code on the client side, how many javascript syntax errors are you going to generate with that cfquery embedded in your javascript code? Moreover, assuming you were able to run that query on the client-side and return the query results, you're not doing anything with it in the above example. You're just running a query, you're not assigning it to anything. – Shawn Grigson Jan 26 '11 at 22:52
  • Right, I took that part out because I wanted to give the least amount of code to get the point across of what I wanted to do. I'm sorry I didn't understand the client/server issues, why are you angry? – Jon Sandness Jan 26 '11 at 23:32

2 Answers2

4

You are mixing server side code with client side code.

  • cf is processed on the server.
  • jquery is processed on the browser, there is no way for this to interact with what has already been and gone on the server.

Sequence of events:

  1. CF parses a source file and produces HTML. The HTML contains your jQuery code.
  2. CF sends the output to a web browser
  3. Web browser renders the data and has the definition of the change event
  4. User changes selection .. code cannot run on the server!

If you View Source on the browser page in 3, the CF code has already finished processing on the server and all you get is the output.

RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
-1

Here some example to query on ColdFusion :

<cfquery name="anyNAME" datasource="your datasource">
SELECT *yourCOLUMN* FROM *tableName*
</cfquery>

Here example how to output the data from MySQL

<cfoutput query="anyNAME">
<textarea> #yourCOLUMN# </textarea>
</cfoutput>

This is a simple mimple easy of ColdFusion code

Kijiya
  • 31
  • 9