Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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
  #1 (permalink)  
Old December 1st, 2005, 06:55 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: Funtion 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();">

  #2 (permalink)  
Old December 1st, 2005, 07:40 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

The line...
Code:
validateFile = false;
Is replacing your validateFile() method with a bool variable.

Try replacing it with...
Code:
var validateFile = false;
BTW, validateFile() is not returning any values at the moment, you need a return statement.

HTH,

Chris

  #3 (permalink)  
Old December 5th, 2005, 02:48 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

Hi,

I will, for the moment, put this problem aside.. This code is just an enhancement anyway. As the saying says: "Good is better than perfect." Got still to finish some parts of this site. Anyway, I have another problem. I need to get an ASP page to upload some files. The problem is, ASP pages break execution when the form (enctype="multipart/form-data") contains file fields. (http://www.macromedia.com/cfusion/kn...fm?id=tn_16542) /sob. do you know any other way to have some upload functionality in ASP pages? or any info on where I can get answers to this?

Thanks

  #4 (permalink)  
Old December 6th, 2005, 07:05 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

This question is not related to asp databases, please post in the dreamweaver forum.

  #5 (permalink)  
Old December 6th, 2005, 08:17 PM
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

Oh.. I'm sorry.. I just want to inform those who helped that I will put this problem aside FOR THE MOMENT.

Thanks for the info anyway. :)



Similar Threads
Thread Thread Starter Forum Replies Last Post
CS1002: ; expected error belete ASP.NET 2.0 Professional 9 November 21st, 2007 01:35 PM
Object expected error hericles Javascript How-To 1 July 19th, 2007 10:21 AM
"Identifier expected" Error NehaJani VB.NET 2002/2003 Basics 6 January 23rd, 2006 11:27 PM
Error: Function expected lameneural Java Basics 0 December 1st, 2005 06:57 AM
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.