Ok so I have some code here and essentially what I want it to do is, I have text files 1.txt, 2.txt… etc that have variables mydata1, mydata2… etc in them respectively. if I load the txt files manually i.e.
<script type = “text/javascript” src=”/home/dillon/Documents/test/1.txt”></script>
<script type = “text/javascript” src=”/home/dillon/Documents/test/2.txt”></script>
Then this script works, however when I try to use a loop for the same purpose it does not work. Is there a way to write javascript with javascript?
<html>
<head>
<script language = “JavaScript” >
function loadz() {
var display = “”
var idisplay
var start = “1”
for(start = 1; start < 10; start++) {
idisplay = (“<script type = “text/javascript” src=”/home/dillon/Documents/test/” + start + “.txt”></script>
display = display + ” ” + idisplay
document.getElementById(‘boldStuff’).innerHTML = display
}
}
</script>
<b id=”boldStuff”></b>
</head>
<BODY onLoad=”loadz()”>
<script language=”JavaScript”>
function checkfile()
{
if (window.mydata1 === undefined) {
alert(“mydata is undefined/undeclared”);
}
else {
alert(“mydata is ” + mydata1 + mydata2 + mydata3);
}
}
</script>
Check for mydata
<form name=”myForm”>
<input type=”Button” value=”Check file” onClick=’checkfile()’>
</form>
</body>
</html>