View Full Version : Choose which .js file to use

08-02-2006, 03:27 PM
Howdy all,

If I have two separate .js files and a particular field on a form to use as a lookup, can I dynamically state which .js file to use based on the value of that field?

I'll elaborate further. I have a particular HTML form that gets updated once per year. Enough elements change on that form to govern separate functions annualy for example, a 2005.js and a 2006.js. Can I perform a lookup on a field (say <input type="text" id="Year">) and set the page to run off of 2005.js or 2006.js accordingly?

I'd prefer to use this type of approach rather than have to maintain one single evergrowing .js file. Having one separate file per year would be much easier to maintain [for me] believe it or not.

Please let me know if you have any questions.

- I

08-02-2006, 03:39 PM
Here's another way to describe the above...

I have this line:

<script language="javascript" type="text/javascript" src="http://.../2005.js"><script>

But [if it were this easy] I'd like to achieve something like this instead:

<script language="javascript" type="text/javascript">
function whichyear {
if (document.getElementById('ReviewType').value == '2005 Annual Review')
src = "http://.../2005.js"
if (document.getElementById('ReviewType').value == '2006 Annual Review')
src = "http://.../2006.js"

08-02-2006, 06:33 PM
I figured it out, thanks.