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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interchanging JavaScript & ColdFusion Variables 1

Status
Not open for further replies.

powahusr

Technical User
Joined
Jan 22, 2001
Messages
240
Location
US
I couldn’t find the answer in any of my CF Books, so I ask you the experts…

When using JavaScript and ColdFusion within the same document, is it possible to set the value of a ColdFusion variable to that of a Variable in JavaScript?

Example:

Say I wanted to do the following…Or something similar

------------------------------------------------------------------------------------
<cfset Var1 = &quot;ColdFusionVariable&quot;>

<cfoutput>

<script type=&quot;text/javascript&quot;>

var jscriptVariable = #Var1#

document.write(&quot;jscriptVariable&quot;)

</script>

</cfoutput>
------------------------------------------------------------------------------------

So when the js document object is run, “ColdFusionVariable” is printed.


Thanks in Advance!!!
 
yes, it's possible.


<cfset varCF = &quot;i'm a viking&quot;>
<cfoutput>
<script language=&quot;javascript&quot;>
var varJS = &quot;#trim(varCF)#&quot;;
document.write(varJS);
</script>
</cfoutput>
 
yes, it's possible.


<cfset varCF = &quot;i'm a viking&quot;>
<cfoutput>
<script language=&quot;javascript&quot;>
var varJS = &quot;#trim(varCF)#&quot;;
document.write(varJS);
</script>
</cfoutput>
 
Thanks, Worked out great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top