Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
| Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2005, 06:57 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to lameneural
Default Error: Function expected

Hi,

I hope I'm not lost.. I have a problem regarding my script(javascript) in Dreamweaver(ASP server). 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? Error points to the red line.

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();">





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object expected error hericles Javascript How-To 1 July 19th, 2007 10:21 AM
Function expected! lameneural Pro Java 1 July 1st, 2006 08:27 PM
"Identifier expected" Error NehaJani VB.NET 2002/2003 Basics 6 January 23rd, 2006 11:27 PM
Error: Funtion expected lameneural Classic ASP Databases 4 December 6th, 2005 08:17 PM
Error "Too Few Parameters - Expected 1" timmaher Access VBA 2 August 31st, 2004 04:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.