Solved

Javascript debugging

Posted on 2012-03-20
6
309 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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 125 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 125 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link Anchor Not working 9 51
Table style position to the left 8 26
javascript works in Chrome, but none of the other browsers 14 37
HTML CSS and  Table design 4 17
Find out what you should include to make the best professional email signature for your organization.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

730 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