How to pass ColdFusion variables to Javascript

Just wrap the <cfoutput></cfoutput> tags around your entire Javascript and then use ColdFusion variables as you would normally.

Example:
<cfset var_name = "Outputting a variable from ColdFusion in JavaScript is easy. Just wrap the <cfoutput></cfoutput> tags around your entire Javascript and then use ColdFusion variables as you would normally.">
<cfoutput>
<script language="javascript" type="text/javascript">
<!--
document.write("#var_name#")
// -->
</script>
</cfoutput>


This will give the following output:
Outputting a variable from ColdFusion in JavaScript is easy. Just wrap the <cfoutput></cfoutput> tags around your entire Javascript and then use ColdFusion variables as you would normally.

Advertisement

McAfee, Inc

No User Comments.

No User Comments, be the first one to write your comments?

ApplayIT is owned by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.