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

CFINCLUDE and JAVASCRIPT

Status
Not open for further replies.

MicahDB

Programmer
Jul 15, 2004
96
0
0
US
ALL,

I'm a .net/classic ASP developer that has inherited a CF site.

I'm done some googling on the subject, but was wondering if someone could give me an answer...can I put javascript inside an include in CF? I know there's a CFSCRIPT tag but I didn't know if that meant that there was a completely different CFSCRIPTing language.

Thanks for the knowledge...

Micah
 
Micah

Just so that you know, cfscript and javascript are different things. cfscript is provided for people that - for some reason - want to write all of their code using the scripting syntax and this is processed on the server and then the result returned to the client. javascript is as i'm sure you'll know is processed on the client machine.

you can get cf and javascript to work together as you would within asp/.net, and for the cf side of things you could use cfml (tag based <cfif a eq 1 etc) or cfscript (scripting based if (a eq 1)).

exampls from macdobe site:
with regard to your question, why not just include the javascript into the page using the usual <script language="javascript" src="whatever.js"></script>

All of the code will then be in its relevant files that way.

Hope this helps!

Tony
 
All,

Thanks for the comments. That's really all I needed to know is yes or no.

As for linking to the script, I just wanted to be able to drop it in my include and be done with it. For ease of personal management and for others to use in the group.

Thanks a bunch!
Micah
 
cfscript is provided for people that - for some reason - want to write all of their code using the scripting syntax

no, cfscript is used to create user defined functions to reuse code easily. Similar to custom tags.

Code:
<cfscript>
 function dFormat(yourDate){
  mask = 'mm/dd/yyyy';
  return dateFormat(yourdate, '#mask#');
 }
</cfscript>

<cfoutput>
 #dFormat(form.aDate)#
</cfoutput>

This isn't a very practical function, just an example. All the processing is done on the server. It doesn't do anything more than a predefined dateFormat function.

If you are unsure of the cfscript syntax (which is just CF in a JS-ish format) you can also use <cffunction> and its associated tags.




We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top