Just like Cascading Style Sheets you can cascade your _javascript_ includes.

You have your common _javascript_ functions you use in files such as:
form_common_ccvalidation.js
form_common_addressvalidation.js
form_common_navigation_tree.js
then for your 20 pages you each have a seperate JS file which imports the necessary _javascript_ libraries/functions as needed, and does wateva it needs to do for that page.

Would you repeat the same ColdFusion code 20 times on 20 pages or write custom includes? Standard programming practices apply just as much to _javascript_ as they do ColdFusion.

This modular approach is also much more bandwith friendly, as the browser will cache each of the included libraries. So, for those 20 JS files, the browser will only be downloading a small bit of code, because it will already have your standard function libraries in its cache.

You could use Steve's bit of _javascript_ to choose the correct _javascript_ file (from the 20) to include, rather than having to hardcode it in... Just give each form a unique 'name' field and name the files 'formname.js'.
<script>
	document.write("<script src="" + document.forms[0].name +  ".js\"></script>");
</script>
Alternatively you could have a single _javascript_ include for all files which has a SWITCH statement to include the correct _javascript_ (you could switch on the URL, so some other unique identifier). This allows you to swap and change the _javascript_ing logic without touching the HTML.

After a while you start to get a library of useful _javascript_ functions - or you can go and grab some off the net and use those (beware of all the crap though).

G'luck.

- tim

Taco Fleur spoke the following wise words on 29/06/2003 5:39 PM EST:
Message
On their own, they are not that big, but when talking about 20 or more forms they start to get big when thrown into one include file. And to throw all that stuff in one JS file is just not what I want to do. Besides I like to know the solution to this issue as it will also come in handy for some other things.
And what you just suggested is a good idea, I will give it a go and see it works.
 
Cheers.

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to