Skip to main content
October 12, 2010
Question

javascript in coldfusion

  • October 12, 2010
  • 2 replies
  • 560 views

Hi All -

I am trying to do the following:

<script language="text/javascript">
  function abc(arg1, arg2) {
     <cfquery name="q" datasource="..">
        select * from table1 where col1 = arg1
     </cfquery>
     ..................
}

</script>

Is it possible to pass javascript arguments to a coldfusion query which is in turn present in the javascript block?
This topic has been closed for replies.

2 replies

ilssac
Inspiring
October 12, 2010

As said in House of Fusion.

No, not at the same time.

ColdFusion executes on the server, and JavaScript executes on the client, never will the twain meet.  They execute on completely different computers using completely different memory with completely different variables, running completely different code at completely different times.

There are plenty of ways to have javascript make requests to a ColdFusion server (i.e. AJAX) and it is trivial to have ColdFusion generate JavaScript to send to the browser.  Just note that they are NOT working together.

Community Expert
October 12, 2010

No, you can't pass JavaScript arguments to CFML within the same page. CFML executes on the server, generating text which is sent to the browser. Once that happens, the browser can execute any JavaScript within the text as appropriate.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Dave Watts, Eidolon LLC