• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

syntax error in javascript file

I have this code in a js file and it keeps coming back syntax error line 3.  Can someone tell me why

function ShowTable(i)
{
    if (i == 1)
     {
         document.getElementById("TableAdd").style.display = "block" ;
     }

}
0
mgmhicks
Asked:
mgmhicks
  • 3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
If 'i' is valid, that code works fine in IE8 and Firefox.
0
 
BadotzCommented:
If "i" is not a number (or something that evaluates to a number) you might get an error.
0
 
BadotzCommented:
//
function ShowTable(i) {
    i = (i || 1); // If "i" is undefined, give it a value
    
    if (i == 1) {
         document.getElementById("TableAdd").style.display = "block" ;
     }
}
//

Open in new window

0
 
mgmhicksAuthor Commented:
I believe my problem is that I am using a master file with my page, and that resides in root.  The page that runs the script is in a folder below that.  Once I moved the js file to that folder it stopped erroring.  

I would like the js file to be accessable no matter what folder I am in.  any ideas.  Here is the code in the master file.
<script type="text/javascript" src="eSiteCompanion.js">
</script
0
 
BadotzCommented:
Without a directory in the src attribute, the browser will look in the same folder in which the page resides.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now