Ioannis:

Unfortunately, this is not possible.  Here's what happens when someone
requests one of your ColdFusion pages.

1. The browser sends an HTTP response to your web server.
2. The web server hands over the request to ColdFusion.
3. ColdFusion then parses all of the CFML in your page and creates the
final HTML/JS code.
4. The web server sends the completed page back to the browser.

Now, any Javascript that you have on the page can only manuipulate data
or HTML elements that exist on that final web page.  It is a language
meant to manipulate the client (browser).  Javascript has no knowledge
of ColdFusion since ColdFusion is a server-side engine.

Since you are a self-admitted newbie, this is the route you can take at
this point...

If you want a Javascript function to have any impact on what ColdFusion
does, you have to generate a new HTTP request back to the server.  For
example, your onClick() function would have to force the browser to go
to a new page -
onClick="javascript:document.location('generateDOM.cfm?param1=x&param2=y
')" - passing along any URL parameters that you might need.  Now
ColdFusion gets involved again as the function you need is inside the
generateDOM.cfm page.

ColdFusion and Javascript do not interact with each other.  Some other
people have mentioned AJAX
(http://en.wikipedia.org/wiki/Ajax_%28programming%29) which operates on
the same principle.  AJAX generates a new HTTP request back to your
server and ColdFusion then responds with some new HTML/JS.  The only
difference is that AJAX makes it look like this didn't happen since the
user is not directed to another page.

Hope that helps,


Steve Brownlee
http://www.fusioncube.net/


-----Original Message-----
From: Ioannis Papanikolaou [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 27, 2006 2:59 PM
To: CF-Talk
Subject: Calling a ColdFusion Function with Javascript

Hello people,

Do you know how can I actually call a Coldfusion funsction with a
javascript function.

for example I am using onClick to call a cffunction inside a div. (DOM)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:265172
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to