[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Javascript debugging

Posted on 2012-03-20
6
Medium Priority
?
314 Views
Last Modified: 2012-03-21
Hi,
I have some simple code that I need to 'debug'.  I dont really know anything about javascript - so I've been trying to use various debuggers, such as JSLint, Microsoft Script Debugger etc.  I'm really struggling to get this done so wondering if someone out there could help me - you can probably identify the errors just by looking at the code... but I'm not that good!
0
Comment
Question by:eyedropp
[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
6 Comments
 
LVL 3

Expert Comment

by:VisionAmp
ID: 37744576
Are you looking for a debugger or help debugging your code from EE, I don't see the code
0
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37744620
Just use firefox and install firebug free firefox plugin. This is the best & simple js debugger i have ever seen. After installing FireBug in firefox, just press F12 and open your page,it will show (in console tab) error inside the firebug.
0
 

Author Comment

by:eyedropp
ID: 37744838
Well either VisionAmp!  I thought I had attached the code.  Not sure what happened there - I'll paste it in here.

I have tried Firebug but it doesnt detect any errors for this code.  But I KNOW there are errors in it.

The code is:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<title>Multiplication Tables</title>
<style type="text/css">
body {font-family: verdana, arial, sans serif; font-size: 1em;}
p {color: #FF0000;}
</style>
</head>

<body>      
<div align="center">
<table border="0" width="95%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<!--Source: http://www.sislands.com/jscript/examples.htm-->
<h1>Multiplication Table Using Nested Loops</h1>
<script type="text/javascript" language="javascript">

    document.write("<p><b><pre>"<blockquote>")
    var  i, j, total;   // global variables

    for (id = 1; i <= 10; i++) {
       for (j = 1; j < 10; j++)
           total = i * j;
           total = " " + total   //add space before each number
           // Add another space before single digits
           if total < 10 total = " " + total;
           
          //Display result
                  document.write (total);
        } // end inner j loop
       document.write ("<br />");    // end of line break
     } // end of i outer loop
     document.write("</blockquote></pre></b></p>")

</script>
</td>
</tr>
</table>
</div>

</body>
</html>


Thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 500 total points
ID: 37744909
replace your code inside <script> .. </script> with the following code

document.write("<p><b><pre><blockquote>")
  var  i, j, total;   // global variables

  for (id = 1; i <= 10; i++) {
     for (j = 1; j < 10; j++)
      {   total = i * j;
         total = " " + total   //add space before each number
         // Add another space before single digits
         if (total < 10) total = " " + total;
         
        //Display result
                document.write (total);
      } // end inner j loop
     document.write ("<br />");    // end of line break
   } // end of i outer loop
   document.write("</blockquote></pre></b></p>")

This will fix your error.
0
 
LVL 14

Assisted Solution

by:Designbyonyx
Designbyonyx earned 500 total points
ID: 37744988
Something seems fishy about this line:

for (id = 1; i <= 10; i++) {

There is no variable "id" - get rid of the "d"

for (i = 1; i <= 10; i++) {
0
 

Author Closing Comment

by:eyedropp
ID: 37746470
Fantastic - thanks for your help! The code is now doing what it should!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

656 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