Tom de Neef a écrit :
"SAM" <st*********************@wanadoo.fr.invalidschre ef in bericht
news:47*********************@news.orange.fr...
>perhaps can you insert the text file via php or something like that ?
(snip)
>
I appreciate your suggestion, but I think I should master Javascript first,
before venturing into php or Ajax.
I don't see JS reading a simple text file (or including it) ...
At least you'll have to transform the text file in a variable or in a JS
array.
file 'testsText.js' :
var lines = '1st line;2nd line;3rd line';
or :
var lines = ['1st line','2nd line','3rd line'];
or :
var lines = [
'1st line',
'2nd line',
'3rd line'
];
(that was supposed the php to do)
(using your original file without to modify it by yourself)
(no ' will be allowed in any line)(php translated that)
(after all, perhaps your C script can create this file ?)
And in the head of your main html page
<script type="text/javascript" src="testsText.js"></script>
<script type="text/javascript">
if(typeof(lines) == 'string') lines = lines.split(';');
function newTest() {
return lines[Math.floor(Math.random()*lines.length)];
}
</script>
In the body of my idea the call to correction was made server-side and
the result displayed in a popup to do not use Ajax.
If you have a file with corrected lines you can load it in same way as
above and compare the answer with correspondent corrected line
then display result somewhere in same page without using Ajax.
But take care you'll force to load 2 files of 600 lines each (which
weight that will be ?)
--
sm