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

javascript in coldfusion

Guest
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

458

Translate

Translate

Report

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
Community Expert ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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
Documentation