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

Javascript debugging

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
eyedropp
Asked:
eyedropp
2 Solutions
 
VisionAmpCommented:
Are you looking for a debugger or help debugging your code from EE, I don't see the code
0
 
Lalit ChandraCommented:
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
 
eyedroppAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Lalit ChandraCommented:
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
 
DesignbyonyxCommented:
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
 
eyedroppAuthor Commented:
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.

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