Solved

syntax error in javascript file

Posted on 2011-03-12
5
370 Views
Last Modified: 2012-05-11
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
Comment
Question by:mgmhicks
  • 3
5 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 35117019
If 'i' is valid, that code works fine in IE8 and Firefox.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 35118045
If "i" is not a number (or something that evaluates to a number) you might get an error.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 35118061
//
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
 

Author Comment

by:mgmhicks
ID: 35118143
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
 
LVL 29

Accepted Solution

by:
Badotz earned 250 total points
ID: 35118174
Without a directory in the src attribute, the browser will look in the same folder in which the page resides.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now