Solved

multiplication table dont work

Posted on 2011-02-27
5
305 Views
Last Modified: 2012-05-11
hello,

 im tryning to make multiplication table it shuld ask for a table and give the answer like

2x1=2
2x2=4
2x3=6
....
Thanks
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>oefening 5’</title>
	</head>
	<body>
		
		
		<script type="text/javascript">
			
			
		document.write(" Multiplication tables")
		
		function alertUser() 
 		{
 		  getal =  prompt("Which multiplication table you want to see?");
  		}
		
		
  		for(teller=0;teller<11;teller++)
			{
				
			floatsom = getal*teller;
			
			}
		</script
		<form>
  			<input type="Button" name="oneButton" value="Start" onClick="alertUser()">
		</form>
		
		
	</body>
</html>

Open in new window

0
Comment
Question by:kensy11
[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
5 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 34993267




Try this (you enter one multiplier - say 2 - and it will
print 2x0, 2x1, etc) - that's how I understood it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>oefening 5’</title>
	</head>
	<body>


		<script type="text/javascript">


		document.write(" Multiplication tables")

		function alertUser()
 		{
 		  getal =  prompt("Which multiplication table you want to see?");
 		  showOut(getal);
  		}
        function showOut(getal) {
		var s = "";
  		for(teller=0;teller<11;teller++)
			{

			floatsom = getal*teller;
			s += getal + "x" + teller + "=" + floatsom + "\n";

			}
			alert(s);
			}
		</script
		<form>
  			<input type="Button" name="oneButton" value="Start" onClick="alertUser()">
		</form>


	</body>
</html>

Open in new window

0
 

Author Comment

by:kensy11
ID: 34993340
Thank you , thats just what i need.

i have changed the code a bit instead of using alert i use document.write , But i have a problem now the answer is showing like this 4x0=0 4x1=4 4x2=8 4x3=12 4x4=16 4x5=20 4x6=24 4x7=28 4x8=32 4x9=36 4x10=40

i want it to be like this

4x0=0
4x1=4
4x2=8
4x3=12
 4x4=16
 4x5=20
....

I have tried using the <br /> but it dont work i dont know how to do it ? can you please help

Thanks
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34993348
Post your new code, I'll be at my computer in about two hours I'll look at that
0
 

Author Comment

by:kensy11
ID: 34993388
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>oefening 5’</title>
      </head>
      <body>


            <script type="text/javascript">


            document.write(" Multiplication tables")

            function alertUser()
             {
               getal =  prompt("Which multiplication table you want to see?");
               showOut(getal);
              }
        function showOut(getal) {
            var s = "";
              for(teller=0;teller<11;teller++)
                  {

                  floatsom = getal*teller;
                  s += getal + "x" + teller + "=" + floatsom + "\n";

                  }
                  document.write(s);
                  
                  
                  }
            </script
            <form>
                    <input type="Button" name="oneButton" value="Start" onClick="alertUser()">
            </form>


      </body>
</html>
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 34993556

There you go:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>oefening 5’</title>
      </head>
      <body>


            <script type="text/javascript">


            document.write(" Multiplication tables")

            function alertUser()
             {
               getal =  prompt("Which multiplication table you want to see?");
               showOut(getal);
              }
        function showOut(getal) {
            var s = "";
              for(teller=0;teller<11;teller++)
                  {

                  floatsom = getal*teller;
                  s = getal + "x" + teller + "=" + floatsom + "";
                  document.writeln(s);
                  document.writeln("<br>");

                  }



                  }
            </script
            <form>
                    <input type="Button" name="oneButton" value="Start" onClick="alertUser()">
            </form>


      </body>
</html>

Open in new window

0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with mod_substitute 18 78
HTML5 storage and web apps 11 113
Anchor Bookmark 6 34
Phone number mask 4 15
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

759 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