Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multiplication table

Posted on 2010-11-11
6
Medium Priority
?
949 Views
Last Modified: 2012-05-10
Experts,

I'm having trouble creating the multiplication table correctly where it displays 0 * any number up to 9 is 0 -- make the bottom screen shot look like the top screenshot in attached .docx

prob something simple but completely brain dead

thanking you in advance.


 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math Tables</title>
<style type="text/css">
<!--
#form1 table {
	text-align: center;
}
#form1 table {
	text-align: center;
}
#form1 table tr td {
	font-weight: bold;
}
#form1 table caption {
	font-weight: bold;
}
-->
</style>
</head>

<body>
<script type="text/javascript"> 
/* <![CDATA[ */


var arrayOne = new Array(11);

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

  arrayOne[i] = i;

}

var newWindow;

function openWindow() {

  if (!(newWindow)) {

	newWindow = window.open();

  }

}

function closeWindow() {

  newWindow.document.close();

}

/* make a addition table... */
function additionTable() {

  openWindow();
  newWindow.document.write("<table border=1 cellspacing=1 cellpadding=5>");
	
  for (var i = 0; i < 11; i++) {

	newWindow.document.write("<tr>");

	for (var j = 0; j < 11; j++) {

	  newWindow.document.write("<td>" + (i + j) + "</td>");

	}

	newWindow.document.write("</tr>");

  }

  closeWindow();

}

/* make a multiplication table... */
function multiplicationTable() {

openWindow();

newWindow.document.write("<table border=1 cellspacing=1 cellpadding=5>");
     
	  for (var i = 0; i < 10; ++i) {
	 
	    newWindow.document.write("<tr>");
	 
	    for (var j = 0; j < 11; ++j) {
	 
	      newWindow.document.write("<td>" + i * j + "</td>");
	 
	    }
	 
	    newWindow.document.write("</tr>");
	 
	  }
	 
	  closeWindow();
	 
	}


/* ]]> */
</script>
<form id="form1" name="form1" method="post" action="">
  <table width="372" border="15" cellpadding="5" cellspacing="5">
    <caption>
          Addition / Multiplication Tables
    </caption>
        <tr>
          <th width="150" align="center" valign="middle" scope="col">Addition</th>
          <th width="150" align="center" valign="bottom" scope="col"><input type="submit" name="btnadd" id="btnadd" value="Submit" onclick="additionTable()" /></th>
        </tr>
        <tr>
          <td align="center" valign="middle">Multiply</td>
          <td align="center" valign="bottom"><input type="submit" name="btnmultiply" id="btnmultiply" value="Submit" onclick="multiplicationTable()" /></td>
        </tr>
  </table>
      <br />
</form>
</body>
</html>

Open in new window

screenshots.docx

0
Comment
Question by:dvcrdu
[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
  • 2
6 Comments
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 2000 total points
ID: 34115656

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math Tables</title>
<style type="text/css">
<!--
#form1 table {
	text-align: center;
}
#form1 table {
	text-align: center;
}
#form1 table tr td {
	font-weight: bold;
}
#form1 table caption {
	font-weight: bold;
}
-->
</style>
</head>

<body>
<script type="text/javascript"> 
/* <![CDATA[ */


var arrayOne = new Array(11);

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

  arrayOne[i] = i;

}

var newWindow;

function openWindow() {

  if (!(newWindow)) {

	newWindow = window.open();

  }

}

function closeWindow() {

  newWindow.document.close();

}

/* make a addition table... */
function additionTable() {

  openWindow();
  newWindow.document.write("<table border=1 cellspacing=1 cellpadding=5>");
	
  for (var i = 0; i < 11; i++) {

	newWindow.document.write("<tr>");

	for (var j = 0; j < 11; j++) {

	  newWindow.document.write("<td>" + (i + j) + "</td>");

	}

	newWindow.document.write("</tr>");

  }

  closeWindow();

}

/* make a multiplication table... */
function multiplicationTable() {

openWindow();

newWindow.document.write("<table border=1 cellspacing=1 cellpadding=5>");
     	  newWindow.document.write("<tr><td>&nbsp;</td>");
	  for(var i=0;i<11;++i)
	  {
                   newWindow.document.write("<td>" + i + "</td>");
               }
	  for (var i = 0; i < 10; ++i) {
	 
	    newWindow.document.write("<tr>");
                 newWindow.document.write("<td>" + i + "</td>"); 	 
	    for (var j = 0; j < 11; ++j) {
	 
	      newWindow.document.write("<td>" + i * j + "</td>");
	 
	    }
	 
	    newWindow.document.write("</tr>");
	 
	  }
	 
	  closeWindow();
	 
	}


/* ]]> */
</script>
<form id="form1" name="form1" method="post" action="">
  <table width="372" border="15" cellpadding="5" cellspacing="5">
    <caption>
          Addition / Multiplication Tables
    </caption>
        <tr>
          <th width="150" align="center" valign="middle" scope="col">Addition</th>
          <th width="150" align="center" valign="bottom" scope="col"><input type="submit" name="btnadd" id="btnadd" value="Submit" onclick="additionTable()" /></th>
        </tr>
        <tr>
          <td align="center" valign="middle">Multiply</td>
          <td align="center" valign="bottom"><input type="submit" name="btnmultiply" id="btnmultiply" value="Submit" onclick="multiplicationTable()" /></td>
        </tr>
  </table>
      <br />
</form>
</body>
</html>

Open in new window

0
 
LVL 29

Expert Comment

by:Badotz
ID: 34116344
Homework?
0
 

Author Comment

by:dvcrdu
ID: 34116855
teaching myself javascript, the book i'm using is less than helpful, but I'm too stubborn to have my money go to waste.  kinda like the old saying, the lawyer who represents himself has an idiot for a client.
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

Author Closing Comment

by:dvcrdu
ID: 34116857
as all ways, thanks for the help!
0
 
LVL 29

Expert Comment

by:Badotz
ID: 34116882
Pick up a copy of The JavaScript Bible by Danny Goodman, et al. Forget about the lawyers; if you want something done right, do it yourself ;-)
0
 

Author Comment

by:dvcrdu
ID: 34116976
that's too cool. will do.

Thanks!
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

721 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