?
Solved

syntax error in javascript file

Posted on 2011-03-12
5
Medium Priority
?
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 83

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 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

777 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