www.webdeveloper.com
Results 1 to 4 of 4

Thread: FileExists/Function Problem

  1. #1
    Join Date
    Jul 2012
    Posts
    32

    Question FileExists/Function Problem

    I Am Running Into A Problem And Have Narrowed It Down To This Function, As You Can See I Have Tried To DeBug it (some remains are the commented out areas), But I Cannot Figure Out What Is Wrong, Thank You For Your Help!!
    Code:
    		function Check3() {
    			Name2 = document.getElementById('Name').value;
    			FEN = Name2+'.html';
    			//alert ('Check3');
    			if ((EN = 'EN') || (ECN == 'ECN')) {
    				if (FileExists(FEN) == True) {
    					EFE();
    					alert ('IF');
    					}
    				else {
    					alert ('ELSE');
    					lastcheck();
    					};
    				};
    			//lastcheck();
    			//alert ('AFTER LAST CALL');
    			};
    Last edited by iGeekiHackiMatt; 07-21-2012 at 10:27 PM.

  2. #2
    Join Date
    Mar 2011
    Posts
    1,149
    Aside from "True" should probably be "true" and the missing "}" for the end of the function and the stray ";" after the "}" at the end of the code, there aren't any glaring logic errors in the code. What is the problem?

  3. #3
    Join Date
    Jun 2009
    Location
    Miami
    Posts
    118
    You have several major problems. One is that you don't use the 'var' keyword, which is bad practice ALWAYS! You also need to learn how to use the semicolon, which is a statement completer, not used after blocks; you effectively have numerous empty statements by using ';' after blocks.

    You also have an assignment rather than an equality test in your conditional block:

    if ((EN = 'EN')....

    is a common mistake. It has also been noted that boolean keywords 'true' and 'false' are all lowercase.

    You would benefit strongly from using Douglas Crockford's JSLint to check your code, and to read his rules on good coding. JSLint would have caught all that and more.

  4. #4
    Join Date
    Jul 2012
    Posts
    32
    I Did Not See That I Only Put One "=" In The If Statement, And I Am Still A Beginner with JavaScript, And Have Never Properly Learned A Programing Language (as in i have self thought my self through looking at other at code and using Google) So Any/All Advice Is Being Used.

    All My Code Is Working Wonderfully Except This If Statement
    Code:
    if (FileExists(FEN) == true) {
    					EFE();
    					alert ('IF');
    					}
    				else {
    					alert ('ELSE');
    					lastcheck();
    					};
    When I Comment It Out It And Run lastcheck(); without checking for the file with JavaScript it Works Flawlessly, But When I include that if statement The whole code will not run, Mavigozler after i post this i will look up Douglas Crockford's JSLint On Google

    EDIT:
    I Have Also Added The "var" in front of the variables
    Last edited by iGeekiHackiMatt; 07-23-2012 at 03:13 PM. Reason: adding info

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles