Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i use coldfusion code inside javascript?

Status
Not open for further replies.

hazelvenus

Programmer
Jun 20, 2001
4
AE
hi there,
how can i set a coldfusion variable to a javascript variable (js_var = some_cf_var)? in other words, how can i use coldfusion code inside JS?

thanx for help
 
well it's simple:
<script>
var js=0;
....
....
js= <CFOUTPUT>#cfvar#</CFOUTPUT>

</script>
 
You need to include &quot;&quot; if the JS var is a string...

Code:
<cfset cf_var = &quot;hello&quot;>
<cfoutput>
<script language=&quot;Javascript&quot;>
<!--
var message = &quot;#cf_var#&quot;;
alert(message);
//-->
</script>
</cfoutput>

HTH

Phil.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top