Results 1 to 3 of 3

Thread: Choose which .js file to use

  1. #1
    Join Date
    Feb 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Choose which .js file to use

    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

  2. #2
    Join Date
    Feb 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Here's another way to describe the above...

    I have this line:
    Code:
    <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:
    Code:
    <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"
    	}
    }
    </script>

  3. #3
    Join Date
    Feb 2005
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I figured it out, thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •