Function expected!
Hi,
I hope I'm not lost.. I have a problem regarding my script(javascript). I dont understand why the error(Function expected) only appears on the second execution the function. Ex. I entered values(filenames) to boxes and try to upload it. But before that, I checked the files if they are really existing. on the first try, I clicked the button, the page prompted me (through alert();) that the file was not found. (Therefore, the code works...) But on the second time I click the same button, then I have the error "Function expected"!
Can you please help me on this?
Here's my code:
<script language="Javascript">
function try() {
if (document.frm.box.value != '') {
if (validateFile(document.frm.box.value)) {
ok_flag = true;
}
else {
alert("File was not found.");
ok_flag = false;
return false;
}
}
if (ok_flag == true) {
document.frm.submit();
}
}
function validateFile(filespec) {
validateFile = false;
try {
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
validateFile = true;
}
catch(err) {
//alert(err.number + ": " +err.message);
if (err.message == 'Automation server can\'t create object') {
alert("");
}
else {
strMessage = "Unexpected error: " + err.message;
alert(strMessage);
}
}
}
</script>
for the button:
<input name="btntry" type="button" value="Try" onClick="javascript:try();">
|