Link to home
Start Free TrialLog in
Avatar of jasch2244
jasch2244

asked on

cfoutput in javascript?

I'm currently using a menu system that utilizes javascript (.js file). I'm using the menu system for a drill down application in coldfusion. My problem is I can't pass a url variable that is dynamic using <cfoutput>#variablename#</cfoutput>. Is there a work around for this?

I've tried wrapping the javascript reference in the .cfm file in <cfoutput> tags from a previous forum  but that does not seem to work.
'*../../LISTINGS/Feedback_Service/Admin_Market_Statistics_Center.cfm?charttype=mynkyhome&ListingId=<cfoutput>#ListingID#</cfoutput>','','','',0,0,2,'#ffffff',

Open in new window

Avatar of SidFishes
SidFishes
Flag of Canada image

you just have to include the js file with a cfm extension


create a file called testjs.cfm
 
<cfoutput>
<cfset var="Hello world">
function hello()
{
	alert('#VAR#')
}
</cfoutput>
 
then do your include
<script type="text/javascript" src="testjs.cfm"></script>
<button onclick="hello();">Say Something</button>

Open in new window

Avatar of jasch2244
jasch2244

ASKER

If I'm understanding you correctly you want me to overwrite the current my.js file with my.cfm file and reference the my.cfm file in the javascript call. If that is what you want me to do... it does not work for this instance, when I do this the drop down menus with the funcitonality in the .js file no longer work.
no... just rename your .js file to .cfm and change your include from

<script type="text/javascript" src="myinclude.js"></script>

to

<script type="text/javascript" src="myinclude.cfm"></script>
Exactly this is what I did.... I do have a script that is trying to send a variable into the .js soon to be .cfm file. This might be messing it up how would I correct this being it's a coldfusion variable ? See code snippet.

Also, in the .js file there are multiple references to hexidicimal color values of #660000 do these all need to be changed as well. Not understanding how the javascript is to run if it's coldfusion code now....
<script type="text/javascript">var PLHFO_ID="PLHFO0"</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial