I have the following HTML file.
I want it to select the correct external javascript file to use.
NOTE: Each version of the .js file has same variable names, just different info.
Does anyone know of a way to change the .js file contents to use in the display?
HTML:
[code=php]
<html>
<head>
<title>External JS Re-Loader</title>
<script type=”text/javascript” src=”old.js”></script>
<script type=”text/javascript” src=”new.js”></script>
<script type=”text/javascript” src=”now.js”></script>
<script type=”text/javascript”>
function DisplayJSContents(JSfile) {
alert(‘File to use: ‘+JSfile);
// here is where I would like to select file version to use. ??? HOW ???
var str = ‘Start Date: ‘+StartDate+”n”;
str += ‘Schedule for: ‘+Schedule[0]+”n”;
str += ‘Data display: ‘+Schedule[1]+”n”;
document.getElementById(‘TA’).value = str;
}
</script>
</head>
<body>
<h2>External JS Re-Loader</h2>
<input type=”radio” id=”JSload” name=”JSload” onChange=”DisplayJSContents(this.value)” value=”old.js”>Old
<input type=”radio” id=”JSload” name=”JSload” onChange=”DisplayJSContents(this.value)” value=”now.js”>Now
<input type=”radio” id=”JSload” name=”JSload” onChange=”DisplayJSContents(this.value)” value=”new.js”>New
<p />
Contents of current JS file loaded<br />
<textarea id=”TA” rows=”5″ cols=”30″></textarea>
</body>
</html>
External JS file: old.js
[code=php]
// old.js
var StartDate = “06/01/2006”;
Schedule = new Array(“Summer”,”Standard data”);
External JS file: new.js
[code=php]
// new.js
var StartDate = “01/01/2007”;
Schedule = new Array(“Spring”,”Standard data”);
External JS file: now.js
[code=php]
// now.js
var StartDate = “08/01/2006”;
Schedule = new Array(“Fall”,”Standard data”);
Program runs fine without reporting errors.
I just cannot figure out how to reload the different external JS files.
Any ideas are appreciated.