Solved

Javascript debugging

Posted on 2012-03-20
6
304 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 7

Accepted Solution

by:
Lalit Chandra earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Fantastic - thanks for your help! The code is now doing what it should!
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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

763 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

14 Experts available now in Live!

Get 1:1 Help Now